How i can flip the y-axis?

758 visualizaciones (últimos 30 días)
Thiago Petersen
Thiago Petersen el 31 de En. de 2017
Movida: Dyuman Joshi el 6 de Jul. de 2025
Hello,
In the following code:
a = [180 170 150 90 45 5 0 -5 -30 -70 -100 -125 -150 -175];
b = [1 2 3 4 5 6 7 8 9 10 11 12 13 14];
plot (a, b,'.')
How i can plot the b variable (as the y-axis) with the high numbers down and the low numbers up in the plot?
Thanks
  2 comentarios
Abdullah Mohmmed
Abdullah Mohmmed el 10 de Sept. de 2020
Movida: Dyuman Joshi el 6 de Jul. de 2025
Code maxwell
Sparsh Garg
Sparsh Garg el 27 de Jul. de 2021
Movida: Dyuman Joshi el 6 de Jul. de 2025
code maxwell??

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 31 de En. de 2017
After your plot call, add this line:
set(gca, 'YDir','reverse')
See the documentation for Axes Properties for details.
  2 comentarios
Rahmawati Rahmawati
Rahmawati Rahmawati el 3 de Jun. de 2018
it works for my case, Thank you
Star Strider
Star Strider el 3 de Jun. de 2018
My pleasure.

Iniciar sesión para comentar.

Más respuestas (1)

Stalin Samuel
Stalin Samuel el 31 de En. de 2017
Editada: Stalin Samuel el 31 de En. de 2017
If you planning to change the ylabel use
set(gca,'YtickLabel',14:-2:0)
Or else, if you wants to flip b alone you can use
fliplr(b)

Categorías

Más información sobre Surfaces, Volumes, and Polygons 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