フィルターのクリア

text label above the bars

66 ビュー (過去 30 日間)
Rene Sebena
Rene Sebena 2016 年 7 月 2 日
コメント済み: Rene Sebena 2016 年 7 月 3 日
Hi there,
I am new in matlab and I am trying to put text labels above the bars, so that A is above first one, B above second one etc...Can you help me with this
thank you
R
y = [10,20,30,15];
a = bar(y);
labels = {'A', 'B', 'C', 'D'};

採用された回答

Star Strider
Star Strider 2016 年 7 月 2 日
This works:
y = [10,20,30,15];
a = bar(y);
labels = {'A', 'B', 'C', 'D'};
xt = get(gca, 'XTick');
text(xt, y, labels, 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
  8 件のコメント
Image Analyst
Image Analyst 2016 年 7 月 3 日
編集済み: Image Analyst 2016 年 7 月 3 日
You've never mentioned anything about red or blue before. What is read and blue - the text or the bars or both? And what is the "second one of the group"? I see just one group of 8 bars and they're all blue.
When you said "so above 10, 20, 30 and 15 I have to put for example A and above 15,15,15 and 12 label B" it seemed to us that you wanted bar #'s 1,3,5, and 7 to have an A above them, and bars 2,4,6, and 8 to have a B above them (at least that was a guess on my part that matched what you said). Now you've made it confusing again.
Rene Sebena
Rene Sebena 2016 年 7 月 3 日
Yes, my fault, sorry for that, I have groups of bars for several subjects and 4 experimental conditions,.. Subject1 results are [10,20,30,15] and subject2 results are [15,15,15,12] so the matrix is like this:
y = [10 15; 20 15;30 15; 15 12];
and I just need to label subject 1 results with eg. "A" and subject 2 results with label "B".

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by