how to allign plot figure and annotation

1 visualizzazione (ultimi 30 giorni)
Muhammad Haziq
Muhammad Haziq il 12 Feb 2021
Risposto: Vimal Rathod il 19 Feb 2021
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

Risposte (1)

Vimal Rathod
Vimal Rathod il 19 Feb 2021
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

Categorie

Scopri di più su Graphics Performance in Help Center e File Exchange

Tag

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by