2012-08-02 176 views
18

如何反转y_axis? Z是np.array.Thank你在matplotlib中翻转坐标轴grafic

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() 

我有这样的:

enter image description here

我需要这样的: enter image description here

+0

Curtsey of [this](http://old.nabble.com/How-to-reverse-the-direction-of-an-axis--td15170464.html)后,您可以使用'ax.set_ylim (ax.get_ylim()[:: - 1])'或['ax.invert_yaxis()'](http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.invert_yaxis),其中'ax'是一个'matplotlib.axes.Axes'对象。 – Chris 2012-08-02 13:14:44

+0

[Matplotlib coord。 sys origin to left left](http://stackoverflow.com/questions/1349230/matplotlib-coord-sys-origin-to-top-left) – Chris 2012-08-02 13:14:58

回答

38

正如@克里斯说,这是可以做到用:

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

在'plt。显示()'。

+7

另外,如果没有其他用途用于'ax',那么one-班轮'plt.gca()。invert_yaxis()'也行。 – heltonbiker 2013-09-19 17:22:42