2012-08-01 49 views
7

我写了一个函数模块,它接受两个变量的参数。要绘制,我不得不在独特的函数调用下在Matplotlib imshow中重新调整轴

x, y = pylab.ogrid[0.3:0.9:0.1, 0.:3.5:.5] 
z = np.zeros(shape=(np.shape(x)[0], np.shape(y)[1])) 

for i in range(len(x)): 
    for j in range(len(y[0])):  
     z[i][j] = fancyFunction(x[i][0], y[0][j]) 

pylab.imshow(z, interpolation="gaussian") 

我得到的图像如下: enter image description here

但是,当我试图重新缩放x和y轴以匹配的[0.3范围:0.9:0.1,0。 :3.5:.5]至pylab.imshow(z, interpolation="gaussian", extent=[.3,.9,0.,3.5])我得到

enter image description here

我一直在谷歌上搜索了几个小时,但还是没能找到一种方法,使一平方米情节与刻度不同轴。

谢谢!

回答

6

使用aspect说法:

pylab.imshow(z, interpolation="gaussian", extent = [.3,.9,0.,3.5], aspect='auto') 
+1

哇噢!谢谢!!!!! – 2012-08-01 20:42:39