how to allign plot figure and annotation

1 次查看(过去 30 天)
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

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by