필터 지우기
필터 지우기

draw a specialized bar graph

조회 수: 19 (최근 30일)
Seldeeno
Seldeeno 2014년 4월 26일
답변: dpb 2014년 4월 27일
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
Seldeeno
Seldeeno 2014년 4월 26일
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 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
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...

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by