我有一组数据,包括x和y坐标以及每个坐标的计算值。网格是不规则的,所以现在我已经创建了一个散点图,并将这些值分成若干个单元,以显示在下面链接的img上的等高线。
http://i.stack.imgur.com/m7XHm.png
我想通过使用matplotlib中的imshow/contour功能,通过使用meshgrid,然后对计算值进行插值,来优化此方法。我可以让它工作得很好,但最后我遇到了一个问题:它丢失了没有数据的图像区域(现实生活中的空洞),并将它们连接起来,如下面链接中的图像所示,以获得相同的数据。
http://i.stack.imgur.com/ZCRog.png
我试图找到最好的方法来做这件事,但我没有找到任何帮助。有人有什么建议吗?在
我想我需要在meshgrid阶段修改方法,但我不确定这一点。我的代码如下x=nodalData[:,1] #array of x values from input file
y=nodalData[:,2] #array of y values from input file
#define the linear grid
xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100)
xi, yi = np.meshgrid(xi, yi)
z=Rres #array calculated elsewhere corresponding to x,y pair
#interpolate
zi = scipy.interpolate.griddata((x, y), z, (xi, yi), method='cubic')
#plot
plt.imshow(zi, vmin=z.min(), vmax=z.max(), origin='lower', extent=[x.min(), x.max(), y.min(), y.max()])