How do I reverse the y-axis in image?

480 Ansichten (letzte 30 Tage)
Ali
Ali am 25 Nov. 2014
Beantwortet: Jamel am 7 Jun. 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.

Akzeptierte Antwort

Orion
Orion am 25 Nov. 2014
Bearbeitet: MathWorks Support Team am 27 Nov. 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 Kommentare
Ali
Ali am 25 Nov. 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 am 1 Mai 2018
The problem is this operation also flips the data.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (4)

Chad Greene
Chad Greene am 25 Nov. 2014
And another solution:
axis ij
  2 Kommentare
Iana Ladygina
Iana Ladygina am 4 Mär. 2020
thank you!
Wybekrik
Wybekrik am 24 Apr. 2020
Just what i was looking for!

Melden Sie sich an, um zu kommentieren.


Wagih Abu Rowin
Wagih Abu Rowin am 5 Okt. 2018
set(gca,'Ydir','reverse')
  1 Kommentar
Shushobhit Chaudhary
Shushobhit Chaudhary am 28 Mai 2019
This is the best answer. Thanks a lot. It helped me a lot.

Melden Sie sich an, um zu kommentieren.


Shane
Shane am 25 Nov. 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 am 7 Jun. 2022
How do I reverse the "Interference from Satellite Constellation Communication Link" code, where the direction starts from the opposite way.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by