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

2 visualizaciones (últimos 30 días)
Volkan Yangin
Volkan Yangin el 2 de Abr. de 2017
Comentada: Star Strider el 2 de Abr. de 2017
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

Respuesta aceptada

Star Strider
Star Strider el 2 de Abr. de 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 comentarios
Volkan Yangin
Volkan Yangin el 2 de Abr. de 2017
Thank you, Star Strider.
Star Strider
Star Strider el 2 de Abr. de 2017
My pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by