how to allign plot figure and annotation

2 ビュー (過去 30 日間)
Muhammad Haziq
Muhammad Haziq 2021 年 2 月 12 日
回答済み: Vimal Rathod 2021 年 2 月 19 日
Hi,
I wanted to draw annotation to some specific points in a graph but when I plot these annotation they are not allign to the grapgh. I wanted to to allign both x-axis of graph figure and annotation so I can mark my annotation on the correct points with respect to x axis. Can any one help me how can I can allign them.
I am attaching my code and pictures.
Thanks in advance.
Regards,
Haziq

回答 (1 件)

Vimal Rathod
Vimal Rathod 2021 年 2 月 19 日
Hi,
You could change the position of annotation by changing the X and Y properties of the annotations. These values represent the values relative to the whole figure and the units are normalized.
You could try to assign the "Y" property value of annotation less to make the annotation come down towards X axis and change the "X" property accordingly to make sure the annotation points at the right points.
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y)
hold on
%ar1 for first annotation
ar1 = annotation('arrow',[0.3 0.3],[0.05 0.1]);
c = ar1.Color;
ar1.Color = 'red';
ar1.HeadStyle = 'plain';
hold on
%ar2 for second annotation
ar2 = annotation('arrow',[0.83 0.83],[0.05 0.1]);
c = ar2.Color;
ar2.Color = 'red';
ar2.HeadStyle = 'plain';
Refer to the following link to know more about the properties of annotations

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by