How i can flip the y-axis?

2 050 vues (au cours des 30 derniers jours)
Thiago Petersen
Thiago Petersen le 31 Jan 2017
Commenté : Sparsh Garg le 27 Juil 2021
Hello,
In the following code:
a = [180 170 150 90 45 5 0 -5 -30 -70 -100 -125 -150 -175];
b = [1 2 3 4 5 6 7 8 9 10 11 12 13 14];
plot (a, b,'.')
How i can plot the b variable (as the y-axis) with the high numbers down and the low numbers up in the plot?
Thanks

Réponse acceptée

Star Strider
Star Strider le 31 Jan 2017
After your plot call, add this line:
set(gca, 'YDir','reverse')
See the documentation for Axes Properties for details.
  2 commentaires
Rahmawati Rahmawati
Rahmawati Rahmawati le 3 Juin 2018
it works for my case, Thank you
Star Strider
Star Strider le 3 Juin 2018
My pleasure.

Connectez-vous pour commenter.

Plus de réponses (2)

Stalin Samuel
Stalin Samuel le 31 Jan 2017
Modifié(e) : Stalin Samuel le 31 Jan 2017
If you planning to change the ylabel use
set(gca,'YtickLabel',14:-2:0)
Or else, if you wants to flip b alone you can use
fliplr(b)

Abdullah Mohmmed
Abdullah Mohmmed le 10 Sep 2020
Code maxwell
  1 commentaire
Sparsh Garg
Sparsh Garg le 27 Juil 2021
code maxwell??

Connectez-vous pour commenter.

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by