1. 程式人生 > >6.Matplotlib繪圖--三角剖分圖

6.Matplotlib繪圖--三角剖分圖

1.簡單的三角剖分:

import matplotlib.pyplot as plt
import numpy as np
import random
import matplotlib.tri as tri

count = 4
X = [1,2,3,4]
Y = [1,5,0,1]

triangles = tri.Triangulation(X, Y)
plt.triplot(triangles,'r-')
plt.show()

2.複雜的三角剖分:

count = 100
X = [random.random()*20 for i in range(count)]
Y = [random.random()*10 for i in range(count)]
triangles = tri.Triangulation(X, Y)
plt.triplot(triangles,'r--')
plt.show()