Annotate multipl plots with text

16 ビュー (過去 30 日間)
Karthik Brs
Karthik Brs 2015 年 11 月 11 日
コメント済み: Karthik Brs 2015 年 11 月 11 日
Hello everyone! I am required to annotate multiple line plots with the numbers as can be seen in the figure. I have put the numbers between the lines using 'plot edit toolbar', but I wish to do it in the code. I have tried many commands like annotation, text, ds2nfu, but all commands requires x and y coordinates for the location of annotation. I just need a number, which is unique to that particular line plot to be printed in the manner as can be seen in the figure. Is there any way wherein I can insert these numbers to the respective plots without extracting the location data? Because, I wont be aware of the x and y most of the times! Your inputs are welcome! Thank you in advance!

採用された回答

Thorsten
Thorsten 2015 年 11 月 11 日
編集済み: Thorsten 2015 年 11 月 11 日
Well, you are aware of the x and y pos, because you can plot the line. You can do the following
x = 1:10+randi(10);
y = [rand*x; rand*x; rand*x; rand*x];
plot(x,y')
ind = round([0.5 0.55 0.6 0.65]*numel(x)); % specify the x positions
labels = {'36' '40' '44' '42'}; % the labels of the lines
for i =1:numel(ind)
text(x(ind(i)), y(i, ind(i)), labels{i})
end
  5 件のコメント
Thorsten
Thorsten 2015 年 11 月 11 日
Use
x = a1;
y = [F1 F2 F3 F4]';
and run the modified code above, starting from the fifth line
ind = ....
Karthik Brs
Karthik Brs 2015 年 11 月 11 日
Works like a charm! Thanks a ton!! :)

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

その他の回答 (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