draw a specialized bar graph
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 26 Apr. 2014
Bearbeitet: dpb
am 26 Apr. 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...
Antworten (1)
dpb
am 27 Apr. 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...
0 Kommentare
Siehe auch
Kategorien
Mehr zu Labels and 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!