How do I reverse the y-axis in image?

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 日

11 投票

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 日

16 投票

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 日

12 投票

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 日

2 投票

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 日

0 投票

How do I reverse the "Interference from Satellite Constellation Communication Link" code, where the direction starts from the opposite way.

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

タグ

質問済み:

Ali
2014 年 11 月 25 日

回答済み:

2022 年 6 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by