How do I reverse the y-axis in image?

258 visualizaciones (últimos 30 días)
Ali
Ali el 25 de Nov. de 2014
Respondida: Jamel el 7 de Jun. de 2022
The image function reverses the y-axis so I wanted to reverse it to correct it. I know it has something to do with gca but cannot figure out the right code. Please help me.

Respuesta aceptada

Orion
Orion el 25 de Nov. de 2014
Editada: MathWorks Support Team el 27 de Nov. de 2018
You can change the direction of increasing values along the y-axis by setting the YDir property of the Axes object.
If you want the values to increase from bottom to top (2-D view), then set the value to 'normal'. Alternatively, if you want the values to decrease from bottom to top, then set the value to 'reverse'. For example:
ax = gca;
ax.YDir = 'normal'
  2 comentarios
Ali
Ali el 25 de Nov. de 2014
But my instructor says its not a good idea to reverse the axis because this may cause problems when you add further things. Any idea why?
Royi Avital
Royi Avital el 1 de Mayo de 2018
The problem is this operation also flips the data.

Iniciar sesión para comentar.

Más respuestas (4)

Chad Greene
Chad Greene el 25 de Nov. de 2014
And another solution:
axis ij
  2 comentarios
Iana Ladygina
Iana Ladygina el 4 de Mzo. de 2020
thank you!
Wybekrik
Wybekrik el 24 de Abr. de 2020
Just what i was looking for!

Iniciar sesión para comentar.


Wagih Abu Rowin
Wagih Abu Rowin el 5 de Oct. de 2018
set(gca,'Ydir','reverse')
  1 comentario
Shushobhit Chaudhary
Shushobhit Chaudhary el 28 de Mayo de 2019
This is the best answer. Thanks a lot. It helped me a lot.

Iniciar sesión para comentar.


Shane
Shane el 25 de Nov. de 2014
Alternatively, you can flip the array. Either fliplr or flipud Flip Left-Right, or Up-Down, depending on how your data is.
plot(X, fliplr(Y))

Jamel
Jamel el 7 de Jun. de 2022
How do I reverse the "Interference from Satellite Constellation Communication Link" code, where the direction starts from the opposite way.

Categorías

Más información sobre Graphics Object Programming 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