使用Python绘制轮廓图

时间:2013-12-05 18:09:07

标签: python

我正在尝试制作一张如下图所示的图表:

Example Image

我正在尝试使用包含3列的表格。我知道有可能使用像“origin”这样的程序。我做过类似的事情,但Pythong颜色接缝更好。

我不知道是什么问题,但我猜我没有以正确的方式导入文件。 (该表是.txt文件)Table example

有人可以帮忙吗?

表示例(真实表有超过10000行):

1 个答案:

答案 0 :(得分:0)

看来你有一张x,y,z数据表。在将数据按摩到该功能所需的单独组件后,您可以使用pcolor来显示数据。

from numpy import *
from matplotlib.pyplot import *

Nx = 3
Ny = 3

# This is just creating some sample data
xx, yy = meshgrid(range(Nx), range(Ny))
zz = xx + yy
data = vstack([c.flatten() for c in [xx, yy, zz]]).T

# This is reversing the above operation to get x y and z suitable for pcolor
x, y, z = [data[:, i].reshape(Nx, Ny) for i in range(3)]

# Now you can plot
pcolor(x, y, z)
colorbar()
相关问题