正方形点等高线图

2024-04-19 18:19:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我有3个数据集,X,Y,Z分别是我的轴和数据。它们定义明确,即。 len(X)=len(Y)=len(Z)=len(Z[i])=范围(0,N)内的i。在

我想做一个类似于contourf的图(我已经做过了),但是使用离散轴,比如“轮廓正方形”,其中每个正方形(x,y)都有一个由Z值(即浮点值)给定的颜色。在

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

有人知道怎么做吗?在

谢谢


Tags: 数据len颜色可视化轮廓浮点插值正方形
1条回答
网友
1楼 · 发布于 2024-04-19 18:19:52

您应该使用matshowimshow绘图功能。在

这里的一个重要论点是插值。 检查这个example from the matplotlib gallery以查看一些示例。在

通过使用matshow(),关键字参数被传递到imshow()matshow()设置原点插值=“最近的”)和方面的默认值。在

这是我自己的一个例子。。。在

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

…返回此图:

perfil vertical

相关问题 更多 >