擅长:python、mysql、java
<p>下面是一个用三角网格轮廓法实现的,基于CT的朱例。</p>
<p>如果域不是凸的,则需要为三角剖分提供自己的三角形,因为默认的Delaunay三角剖分将从点网格凸面外壳。</p>
<pre><code>import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.tri as mtri
y = np.array([np.linspace(-i, i, 51) for i in (
np.linspace(5, 10))[::-1]])
x = (np.zeros((50, 51)) +
np.linspace(1, 6, 50)[..., np.newaxis])
z = (np.zeros((50, 51)) -
np.linspace(-5, 5, 51)**2 + 10) # make up some z data
x = x.flatten()
y = y.flatten()
z = z.flatten()
print "x shape: ", x.shape
triang = mtri.Triangulation(x, y)
plt.tricontourf(triang, z)
plt.colorbar()
plt.show()
</code></pre>
<p><img src="https://i.stack.imgur.com/A69xY.png" alt="enter image description here"/></p>