draw a specialized bar graph
17 次查看(过去 30 天)
显示 更早的评论
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
编辑:dpb
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...
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!