mcva
mcva

Reputation: 1265

Invert an axis in a matplotlib grafic

How can I invert the y_axis? Z is a np.array.Thank you

Z=TempLake 

X,Y=np.meshgrid(range(Z.shape[0]+1),range(Z.shape[1]+1)) 
im = plt.pcolormesh(X,Y,Z.transpose(), cmap='hot') 
plt.colorbar(im, orientation='horizontal') 
plt.show() 

I have this:

enter image description here

I need this: enter image description here

Upvotes: 34

Views: 63456

Answers (1)

pelson
pelson

Reputation: 21849

As @Chris said, this can be done with:

ax = plt.gca()
ax.invert_yaxis()

Before the 'plt.show()'.

Upvotes: 62

Related Questions