how to flip the direction of the axis?
Mostrar comentarios más antiguos
Dear all,
I want to change the x-axis direction from right to left but also keeping the values to be not affected (reversed/flipped). when I used the fooling command the mentioned problem is caused:
set(gca, 'XDir','reverse')
How can I solve that?
thanks
Respuesta aceptada
Más respuestas (1)
Oli Fairfax
el 16 de En. de 2025
Editada: Oli Fairfax
el 16 de En. de 2025
You're probably better off reversing the data and the axes rather than playing with the tick lables, in my opinion:
% Example data
x = [1:0.1:10];
y = sin(x);
% Normal plot
figure;
plot(x,y)
% Reversed axes plot
figure
plot(flip(x),y)
set(gca, 'XDir','reverse')
1 comentario
DGM
el 17 de En. de 2025
Yes, sometimes it's necessary to do some combination of flipping the data and/or the axes. This is often an issue when trying to plot data overlaid atop images.
Categorías
Más información sobre Axis Labels en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
