How to name/number each line graph in Y axis, instead of the 1-9 numbers?

2 ビュー (過去 30 日間)
dsp
dsp 2016 年 5 月 11 日
コメント済み: Jos (10584) 2016 年 5 月 12 日
I want to name the line graphs in y axis like this (in red).
Program as follows
for i=1:9
g=GG(:,i)+i;
plot(X,g)
hold on
end
end

採用された回答

Jos (10584)
Jos (10584) 2016 年 5 月 11 日
use the function text
text(X, Y, STR)
will place the string STR at the location (X,Y) on the current axes.
  2 件のコメント
dsp
dsp 2016 年 5 月 12 日
Hi, I want to display the -0.8 to 0.8 in the Y axis instead of the 1 to 9 numbers.
Jos (10584)
Jos (10584) 2016 年 5 月 12 日
Two options,
1) change the tick labels
set(gca,'ylim',[0 10],'ytick',1:9,'yticklabel',arrayfun(@(k) sprintf('%-.1f',k),-0.8:0.2:0.8,'un',0))
2) change the y-values

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2016 年 5 月 11 日
I would set the DisplayName property of each line as I created it, then call legend with the 'show' option afterwards.
M = magic(5);
for k = 1:size(M, 2)
plot(M(:, k), 'DisplayName', num2str(k, 'M(:, %d)'))
hold on
end
legend show
  1 件のコメント
dsp
dsp 2016 年 5 月 12 日
Hi, I want to display the -0.8 to 0.8 in the Y axis instead of the 1 to 9 numbers.

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

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by