我想绘制特定几何(多边形)的等高线图。我有角的坐标和这个多边形内的一些点,我想插入到等高线图中的一维参数。我能够绘制参数的分布,但图像显示为正方形(因为我不知道如何指定我的几何图形)。不用说我是 Python 初学者......
我目前使用以下代码;
import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate
r = np.array([[0, 0, 1.0000], [0, 1.0000, 0], [1.0000, 0, 0], [0, 0.7071, 0.7071],
[0, -0.7071, 0.7071],[0.7071, 0, 0.7071], [-0.7071, 0, 0.7071], [0.7071, 0.7071, 0],
[-0.7071, 0.7071, 0], [0.8361, 0.3879, 0.3879], [-0.8361, 0.3879, 0.3879],
[0.8361, -0.3879, 0.3879], [-0.8361, -0.3879, 0.3879], [0.3879, 0.8361, 0.3879],
[-0.3879, 0.8361, 0.3879], [0.3879, -0.8361, 0.3879], [-0.3879, -0.8361, 0.3879],
[0.3879, 0.3879, 0.8361], [-0.3879, 0.3879, 0.8361], [0.3879, -0.3879, 0.8361],
[-0.3879, -0.3879, 0.8361], [-1.0000, 0, 0], [-0.7071, -0.7071, 0], [0, -1.0000, 0],
[0.7071, -0.7071, 0]])
xx = r[:,0]
yy = r[:,1]
zz = r[:,2]
xxi, yyi = np.linspace(xx.min(), xx.max(), 100), np.linspace(yy.min(), yy.max(), 100)
xxi, yyi = np.meshgrid(xxi, yyi)
rbff = scipy.interpolate.Rbf(xx, yy, zz, function='linear')
zzi = rbff(xxi, yyi)
plt.imshow(zzi, vmin=zz.min(), vmax=zz.max(), origin='lower',
extent=[xx.min(), xx.max(), yy.min(), yy.max()])
plt.scatter(xx, yy, c=zz)
plt.colorbar()
plt.show()