How do I reverse the y-axis in image?

조회 수: 478 (최근 30일)
Ali
Ali 2014년 11월 25일
답변: Jamel 2022년 6월 7일
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.

채택된 답변

Orion
Orion 2014년 11월 25일
편집: MathWorks Support Team 2018년 11월 27일
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
Ali
Ali 2014년 11월 25일
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 2018년 5월 1일
The problem is this operation also flips the data.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Chad Greene
Chad Greene 2014년 11월 25일
And another solution:
axis ij
  댓글 수: 2
Iana Ladygina
Iana Ladygina 2020년 3월 4일
thank you!
Wybekrik
Wybekrik 2020년 4월 24일
Just what i was looking for!

댓글을 달려면 로그인하십시오.


Wagih Abu Rowin
Wagih Abu Rowin 2018년 10월 5일
set(gca,'Ydir','reverse')
  댓글 수: 1
Shushobhit Chaudhary
Shushobhit Chaudhary 2019년 5월 28일
This is the best answer. Thanks a lot. It helped me a lot.

댓글을 달려면 로그인하십시오.


Shane
Shane 2014년 11월 25일
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 2022년 6월 7일
How do I reverse the "Interference from Satellite Constellation Communication Link" code, where the direction starts from the opposite way.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by