How can I add the values to the top of the bars?

조회 수: 2 (최근 30일)
Volkan Yangin
Volkan Yangin 2017년 4월 2일
댓글: Star Strider 2017년 4월 2일
Hi everbody
To add the values of bars (like as the image), what kind of a code can be written?
Thanks...
graf=[10 15]
bar(graf,0.2,'m')
set(gca,'XTickLabel',{'X','Y'})
ylabel( '% ')
grid on

채택된 답변

Star Strider
Star Strider 2017년 4월 2일
Try this:
graf=[10 15]
bar(graf,0.2,'m')
set(gca,'XTickLabel',{'X','Y'})
ylabel( '% ')
xt = get(gca, 'XTick'); % Values For ‘X-Ticks’
text(xt, graf, {'10%','15%'}, 'VerticalAlignment','bottom', 'HorizontalAlignment','center')
set(gca, 'YLim',[0 20])
grid on
  댓글 수: 2
Volkan Yangin
Volkan Yangin 2017년 4월 2일
Thank you, Star Strider.
Star Strider
Star Strider 2017년 4월 2일
My pleasure.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by