【问题标题】:Contour plot in square points方点等值线图
【发布时间】:2012-03-06 06:54:14
【问题描述】:

我有 3 个数据集,X、Y、Z 分别是我的坐标轴和我的数据。它们定义明确,即 len(X) = len(Y) = len(Z) = len(Z[i]) = N for i in range(0,N)。

我想做一个类似于轮廓图的图(我已经做了),但是使用 离散轴,就像“等高线正方形”,其中每个正方形 (x,y) 都有一个Z 值给出的颜色(这是一个浮点值)。

到目前为止,我使用的是 contourf(X,Y,Z),但它会产生一些我不想要的插值,我需要更好的正方形可视化。

有人知道怎么做吗?

谢谢

【问题讨论】:

  • 你所描述的对我来说听起来像imshow

标签: python plot matplotlib


【解决方案1】:

您应该使用 ma​​tshowimshow 绘图功能。

这里的一个重要参数是插值。 检查此example from the matplotlib gallery 以查看一些示例。

通过使用matshow(),关键字参数被传递给imshow()matshow()origininterpolation (='nearest') 和 aspect。

这是我自己工作的一个例子......

# level, time and conc are previously read from a file

X,Y=[level,time]   
Z=conc.transpose() # Create the data to be plotted

cax = matshow(Z, origin='lower', vmin=0, vmax=500)
    # I am telling all the Z values above 500 will have the same color
    # in the plot (if vmin or vmax are not given, they are taken from
    # the input’s minimum and maximum value respectively)
grid(True)
cbar = colorbar(cax)

...返回此图:

【讨论】:

    猜你喜欢
    • 2022-12-10
    • 2016-02-20
    • 2020-06-12
    • 1970-01-01
    • 1970-01-01
    • 2020-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多