Hi. I have the following script (attached )b and the run that it opens can be found at this link.
https://drive.google.com/open?id=0B0wQbicZOF7xN1BXV1FKVVRCT2c
It works perfectly except I want to reverse the the y- axis. I have tried several things but no luck. The only way I found is to do it manually. Is there another way?

 Akzeptierte Antwort

Adam
Adam am 28 Mär. 2017

0 Stimmen

set( hAxes, 'YDir', 'reverse' )
should do this for an axes hAxes.

3 Kommentare

David du Preez
David du Preez am 28 Mär. 2017
I've tried that. It doesn't work
David du Preez
David du Preez am 28 Mär. 2017
set (gca,'YDir','reverse')
In second last line
Adam
Adam am 28 Mär. 2017
So is it working or not now? You accepted an answer so I assume so, but your comment suggests otherwise.
As I mentioned, hAxes is an axes handle, how you get this is up to you. I would never use 'gca' except in a temporary script though, you should keep a handle to your axes and use this explicitly.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

KSSV
KSSV am 28 Mär. 2017

2 Stimmen

N = 10 ;
x = rand(N,1) ;
y = 1:N ;
figure(1)
plot(x,y) ;
figure(2)
plot(x,y) ;
set(gca,'Ydir','reverse')

5 Kommentare

David du Preez
David du Preez am 28 Mär. 2017
I've tried that. It doesn't work
Timothy Buchanan
Timothy Buchanan am 7 Aug. 2019
It worked for me.
Helene Thygesen
Helene Thygesen am 10 Nov. 2020
it worked for me too
Ruslan Askarov
Ruslan Askarov am 26 Mai 2023
it worked for me too. Thanks a lot!
Jahanzeb Saqib
Jahanzeb Saqib am 8 Jun. 2023
Its working for me as well even with barh plot... Many thanks!

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by