我有一个包含 3 列的数据表,我想根据前两列在彩色二维图中绘制第三列。例如对于下表,即
4.0 4.0 0.313660827978
4.0 5.0 0.365348418405
4.0 6.0 0.423733120134
5.0 4.0 0.365348418405
5.0 5.0 0.439599930621
5.0 6.0 0.525083754405
6.0 4.0 0.423733120134
6.0 5.0 0.525083754405
6.0 6.0 0.651536351379
我使用以下代码:
x,y,z = np.loadtxt('output_overlap.dat').T #Transposed for easier unpacking
nrows, ncols = final_step_j-1, final_step_k-1
grid = z.reshape((nrows, ncols))
plt.imshow(grid, extent=(x.min(), x.max(), y.max(), y.min()),
interpolation='nearest',
cmap='binary')
fig1 = plt.gcf()
plt.colorbar()
plt.xlabel('m1')
plt.ylabel('m2')
plt.draw()
fig1.savefig('test.pdf', dpi=100)
close('all')
这给了我以下情节:https://dl.dropboxusercontent.com/u/31460244/test.png https://dl.dropboxusercontent.com/u/31460244/test.png
哪个是对的。现在,我的问题是:如何更改 Y 轴上显示数据的顺序?我希望点 (4,4) 位于原点。
我尝试过改变
plt.imshow(grid, extent=(x.min(), x.max(), y.max(), y.min())
to:
plt.imshow(grid, extent=(x.min(), x.max(), y.min(), y.max())
它确实改变了网格中的数字,但没有改变实际数据。这不是解决方案。有人可以在这里给我帮助吗?