等高线的等高线图

Jor*_*tao 1 python plot matplotlib

我有3个数据集,X,Y,Z分别是我的轴和我的数据.它们被很好地定义,即len(X)= len(Y)= len(Z)= len(Z [i])= N,范围为(0,N).

我想做一个类似于contourf图(我已经做过),但是使用离散轴,比如"轮廓正方形",其中每个正方形(x,y)都有一个由Z值给出的颜色(这是一个浮动值).

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

有谁知道怎么做?

谢谢

car*_*rla 5

你应该使用matshowimshow绘图功能.

这里一个重要的论点是插值.从matplotlib库中查看此示例以查看一些示例.

通过使用matshow(),关键字参数传递给imshow(). matshow()设置origin,interpolation(='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)
Run Code Online (Sandbox Code Playgroud)

...返回此图:

垂直的