不规则X Y Z数据的等值线/显示图 [英] Contour/imshow plot for irregular X Y Z data
本文介绍了不规则X Y Z数据的等值线/显示图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有X,Y,Z格式的数据,所有数据都是一维数组,Z是在坐标(X,Y)处的测量幅度.我想将此数据显示为等高线或"imshow"图,其中等高线/颜色表示Z值(振幅).
I have data in X, Y, Z format where all are 1D arrays, and Z is the amplitude of the measurement at coordinate (X,Y). I'd like to show this data as a contour or 'imshow' plot where the contours/color represent the the value Z (amplitude).
用于测量的网格以及X和Y外观的间距不规则.
The grid for measurements and X and Y look are irregularly spaced.
非常感谢,
len(X)= 100
len(X)=100
len(Y)= 100
len(Y)=100
len(Z)= 100
len(Z)=100
推荐答案
plt.tricontourf(x,y,z)
是否满足您的要求?
它将为不规则间隔的数据(非直线网格)绘制填充轮廓.
It will plot filled contours for irregularly spaced data (non-rectilinear grid).
您可能还想研究plt.tripcolor()
.
import numpy as np
import matplotlib.pyplot as plt
x = np.random.rand(100)
y = np.random.rand(100)
z = np.sin(x)+np.cos(y)
f, ax = plt.subplots(1,2, sharex=True, sharey=True)
ax[0].tripcolor(x,y,z)
ax[1].tricontourf(x,y,z, 20) # choose 20 contour levels, just to show how good its interpolation is
ax[1].plot(x,y, 'ko ')
ax[0].plot(x,y, 'ko ')
plt.savefig('test.png')
这篇关于不规则X Y Z数据的等值线/显示图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文