Borrar filtros
Borrar filtros

draw a specialized bar graph

19 visualizaciones (últimos 30 días)
Seldeeno
Seldeeno el 26 de Abr. de 2014
Respondida: dpb el 27 de Abr. de 2014
Hello,
I am trying to draw a grouped bar graph of three data series and since there is a clear difference in values, I am trying to annotate the value on top of the small bar only. Sample values are as attached. Any ideas?
Thanks
  3 comentarios
Seldeeno
Seldeeno el 26 de Abr. de 2014
Hello This is what I tried so far:
load Data_TC.txt
y=Data_TC
bar(y, 'group')
but I dont know how to add values on top of the smallest bar
dpb
dpb el 26 de Abr. de 2014
Editada: dpb el 26 de Abr. de 2014
doc text % for starters
There's examples in the section on Annotation in the doc's as well...
BTW, you may like the effect of
set(gca,'xtick',1:19)
to align the axes ticks with the bars; you can label them w/ as desired as well w' 'xticklabel' property.
NB: the x-value for your desired labels for the short bar will be 1:19 minus a small delta--the middle bar is centered at the tick and the other two are a consistent delta from that. A little trial and error will show you what that offset should be. Start w/ -0.025 or so...
And, you'll likely want to use the TeX interpreter to be able to rotate the text 90-deg so it will run vertically alongside the others. Follow the links in Annotation and text() to find details there as well...
It's some learning but if you're going to use Matlab may as well learn way around the handle graphics stuff now; it's key to such customization and after a little while you'll get the hang of it...
Take a stab and post back where get really stuck next go 'round...

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 27 de Abr. de 2014
OK, I had a few minutes to spare this morning...try the following for starters...
bar(y,'group')
set(gca,'xtick',1:19)
xt=[1:19]-0.25;
yt=y(:,1)+50;
ytxt=num2str(y(:,1),'%.1f');
text(xt,yt,ytxt,'rotation',90,'fontsize',8,'fontweight','bold')
Salt to suit...

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by