draw a specialized bar graph
古いコメントを表示
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 件のコメント
dpb
2014 年 4 月 26 日
What's the specific problem? You can use text at any position to annotate whatever you choose. The x,y positions of the text are consistent with the data axes so it's essentially trivial to place somewhere near the value(s) desired.
What have you tried and what doesn't work out as you expected/desired?
Seldeeno
2014 年 4 月 26 日
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...
回答 (1 件)
dpb
2014 年 4 月 27 日
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...
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!