Matplotlib coord. sys origin to top left

Nate picture Nate · Aug 28, 2009 · Viewed 24.1k times · Source

How can I flip the origin of a matplotlib plot to be in the upper-left corner - as opposed to the default lower-left? I'm using matplotlib.pylab.plot to produce the plot (though if there is another plotting routine that is more flexible, please let me know).

I'm looking for the equivalent of the matlab command: axis ij;

Also, I've spent a couple hours surfing matplotlib help and google but haven't come up with an answer. Some info on where I could have looked up the answer would be helpful as well.

Answer

G M picture G M · Mar 10, 2016

The easiest way is to use:

plt.gca().invert_yaxis()

After you plotted the image. Origin works only for imshow.