Translation of a plot line

7 visualizaciones (últimos 30 días)
HWIK
HWIK el 20 de Abr. de 2021
Comentada: Walter Roberson el 20 de Abr. de 2021
Considering an existing figure, would it be possible to vertically translate one of the lines of the plot by a certain amount?

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Abr. de 2021
The easiest way is to find the line handle, extract the YData, add the shift to it, and store the result back in the YData property.
  2 comentarios
HWIK
HWIK el 20 de Abr. de 2021
I'll have a look into that, thanks!
Walter Roberson
Walter Roberson el 20 de Abr. de 2021
plot(rand(1,50));
h = findobj(gcf, 'type', 'line');
h.YData = h.YData + 5;
Notice that rand() is strictly in the range 0 to 1, but the plot output is in the range 5 to 6, because the line has been moved up by 5

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Objects en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by