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