bar plot

조회 수: 5 (최근 30일)
Hassan
Hassan 2011년 6월 30일
I am making a bar plot. I want to put text labels for each x value. the text lables, however, are located at the end of each bar on X axis. I wonder how I can put them in the center of bars. I apperciate your help.
  댓글 수: 2
Rick Rosson
Rick Rosson 2011년 6월 30일
Can you please include the code you are calling to make the bar plot? Also, can you please post a screen shot of the resulting figure window? Thanks.
Hassan
Hassan 2011년 6월 30일
Hi Rick,
n=[3237 8359 1381 9172 3737 3548 7582]
l={'oilseed rape','wheat','bare soil','grassland','built-up','field beans','barley'};
bar(n)
set(gca,'xticklabel',l.')

댓글을 달려면 로그인하십시오.

채택된 답변

Paulo Silva
Paulo Silva 2011년 6월 30일
Using my magic ball I will try to answer the question with one example made by me and based on the reference at the bottom
fruit = [2 5 6 7]
h=bar(fruit)
l={'apples', 'oranges', 'strawberries', 'pears'}
y=get(h,'Ydata');
x=get(h,'Xdata');
text(x-x(1)/3,y/2,l,'FontSize',18)
  댓글 수: 3
Paulo Silva
Paulo Silva 2011년 6월 30일
Can you please stop calling me Paula?
My answer is exactly what you asked on your first question and now you are asking the easy part
fruit = [2 5 6 7]
bar(fruit)
set(gca,'XTickLabel',
{'apples', 'oranges', 'strawberries','pears'})
Hassan
Hassan 2011년 6월 30일
Sorry Paulo for misspelling your name. Thanks a lot for the help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by