about Grigoris Maravelias
Reverse axis in matplotlib’s plot

Reverse axis in matplotlib’s plot

Ok, maybe this post is not that important but it is one of the things that, although they seem so simple, you struggle to find the answer. After having downloaded matplotlib (a powerful library for 2D plots) my first plot through python was a success. But since I was plotting magnitudes I wanted the axis to be reversed. So, it took almost half a day to find out how :

plt.ylim(plt.ylim()[::-1])

where “plt” is “matplotlib.pyplot”.

Thanks to JK-2’s answer !!

Leave a Reply

Your email address will not be published. Required fields are marked *