How plot a line segment with arrowhead?

Hey do I plot line segments like in this picture? And maybe could tell me someone how to do the arrows?

Respuestas (1)

Image Analyst
Image Analyst el 11 de Dic. de 2022
Editada: Image Analyst el 11 de Dic. de 2022

0 votos

To plot arrows, you can use annotation
To plot line segments with no arrowheads, you can use line or plot

4 comentarios

N/A
N/A el 12 de Dic. de 2022
Thank you, Is it possible to put many lines, for example for each segment in the number, in one or two lines?
Because now i had to put for each line in the number one of x and y variable and the line syntax for them.
It’s seems like there would be an easier way to do it.
You can plot many lines with plot but you have to put a nan in between the points. I'm not sure that's easier than just plotting in a loop. It's probably not but here is how you can do it
x = 1:10;
y = randi(9, 1, length(x));
subplot(2, 1, 1);
plot(x, y, 'b.-', 'LineWidth', 2, 'MarkerSize', 18);
grid on;
% Make a section nan so it won't draw a line there.
hiddenrange = 5:7;
x(hiddenrange) = nan;
y(hiddenrange) = nan;
subplot(2, 1, 2);
plot(x, y, 'b.-', 'LineWidth', 2, 'MarkerSize', 18); % Nan values won't draw
grid on;
Brian LaRocca
Brian LaRocca el 27 de Nov. de 2024
Using annotate with data drawn using plot is awkward since the two do not share the same coordinate system.
Brian LaRocca
Brian LaRocca el 27 de Nov. de 2024
quiver and quiver3 get around this, but the arrows may not look that great. There should be a better solution.

Iniciar sesión para comentar.

Categorías

Más información sobre Line Plots en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Etiquetas

Preguntada:

N/A
el 11 de Dic. de 2022

Comentada:

el 27 de Nov. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by