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

2 次查看(过去 30 天)
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

更多回答(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