Invert image displayed by imshow in matplotlib


I wanted the imshow() function in matplotlib.pyplot to display images the opposite way, i.e upside down. Is there a simple way to do this?

Asked By: pratikm



Specify the keyword argument origin='lower' or origin='upper' in your call to imshow.

Answered By: wim

add .T after the data you want to plot


This will “transpose” the data

Answered By: Ben Pickering

You can use the extent argument. For example, if X values range from -10 and 10 and Y values range from -5 to 5, you should pass extent=(-10,10,-5,5) to imshow().

Answered By: Nbarjest

Use ax.invert_yaxis() to invert the y-axis, or ax.invert_xaxis() to invert the x-axis.

Answered By: Nirmal
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.