plotting values in in reverse order

94 visualizaciones (últimos 30 días)
Ester
Ester el 17 de Dic. de 2015
Comentada: Star Strider el 29 de Ag. de 2022
I would like to plot my X-axis values in the reverse direction. I mean if they are A= [ 0 1 2 3 4 5 ] Then instead of plotting them from 0 to 5 I would like to plot them from 5 to 0. I did plot(fliplr(x),y);set(gca,'xdir','reverse') and the labels of the x axis are reversed but the data is still plotted in the same direction. How can I reverse the direction in which the data is plotted?
THANKS! (o:
Ester

Respuestas (1)

Star Strider
Star Strider el 17 de Dic. de 2015
Set the x-axis direction 'XDir' to 'reverse':
Example:
x = 0:5;
y = 3 + 2*x;
figure(1)
subplot(2,1,1)
plot(x, y)
grid
subplot(2,1,2)
plot(x,y)
set(gca, 'XDir','reverse')
grid
  5 comentarios
Bruno Luong
Bruno Luong el 29 de Ag. de 2022
Editada: Bruno Luong el 29 de Ag. de 2022
@Ana Gonçalves 'XDir' is an axes property not figure
Star Strider
Star Strider el 29 de Ag. de 2022
Following up on that —
x = 0:5;
y = 3 + 2*x;
figure(1)
subplot(2,1,1)
plot(x, y)
grid
subplot(2,1,2)
plot(x,y)
grid
Kids = figure(1).Children;
Kids(1).XDir = 'reverse';
NOTE — In this instance (using subplot) the second subplot is the first axes object.
.

Iniciar sesión para comentar.

Categorías

Más información sobre Discrete Data Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by