필터 지우기
필터 지우기

how to write the legend in bar chart

조회 수: 2 (최근 30일)
Ibrahim AlZoubi
Ibrahim AlZoubi 2020년 5월 3일
댓글: Ibrahim AlZoubi 2020년 5월 3일
how to add legend for the first, second and third column?
this is the code:
y =[44,55,54] ;
b = bar(y,0.5);
bar(y)

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 3일
편집: Ameer Hamza 2020년 5월 3일
Try this
y =[44,55,54];
hold on
for i=1:numel(y)
bar(i, y(i))
end
legend({'first', 'second', 'third'})
  댓글 수: 14
Ameer Hamza
Ameer Hamza 2020년 5월 3일
You can replace A, B and C with what you want
y =[44,55,54];
hold on
for i=1:numel(y)
bar(i, y(i))
end
xticks(1:numel(y))
xticklabels({'44', '55', '54'})
legend({'first', 'second', 'third'})
Ibrahim AlZoubi
Ibrahim AlZoubi 2020년 5월 3일
thank you sir it worked thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by