How to put the text on the top of the line?

58 ビュー (過去 30 日間)
muhammad choudhry
muhammad choudhry 2020 年 10 月 1 日
回答済み: Ameer Hamza 2020 年 10 月 1 日
Hi,
I have plot on the graph few horizontal lines and I would like to put some text on it, plots are shown below.
can anyone help!
Code:
Line 1:
y = 641;
plot ([0,100],[y,y],'Color',[0.6350, 0.0780, 0.1840],'LineStyle','--','LineWidth',1.5)
hold on
I want to put the text on the top of this line: " 641 is the invert limit"
Line 2:
y = 200.1;
plot ([0,100],[y,y],'Color',[0.4940, 0.1840, 0.5560],'LineStyle','--','LineWidth',1.5)
hold off
I want to put the text on the top of this line: " 200.1 is the maximum limit"
I tried this way but getting an error:
text(40,200.1),'200.1 is the maximum limit)
Error:
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise,
check for mismatched delimiters.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 1 日
You can generally use text(). In this case, yline() is easier
ax = axes();
hold on
y = 641;
yline(y, '--', '641 is the invert limit', ...
'FontSize', 14, ...
'LabelHorizontalAlignment', 'center');
y = 200.1;
yline(y, '--', '200.1 is the maximum limit', ...
'FontSize', 14, ...
'LabelHorizontalAlignment', 'center');

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