How can I add the values to the top of the bars?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Volkan Yangin
am 2 Apr. 2017
Kommentiert: Star Strider
am 2 Apr. 2017
Hi everbody
To add the values of bars (like as the image), what kind of a code can be written?
Thanks...
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162517/image.gif)
graf=[10 15]
bar(graf,0.2,'m')
set(gca,'XTickLabel',{'X','Y'})
ylabel( '% ')
grid on
0 Kommentare
Akzeptierte Antwort
Star Strider
am 2 Apr. 2017
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!