pyplot의 triplot 함수를 사용하여 scipy.spatial.Delaunay에 의해 생성 된 삼각형 목록을 그려서 각 삼각형을 그릴 수 있고 개별 색상으로 채울 수 있습니까? 내가 만든 기본 파이썬 스크립트는Matplotlib triplot의 삼각형을 개별 색상으로 채우기
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Delaunay
import matplotlib.image as mpimg
h = 300
w = 1000
npts = 30
pts = np.zeros((npts,2))
pts[:,0] = np.random.randint(0,w,npts)
pts[:,1] = np.random.randint(0,h,npts)
tri = Delaunay(pts)
plt.xlim(0, w)
plt.ylim(0, h)
# Determine the color used for each triangle based upon the orthocenter
# of the triangle and the corresponding pixel color in a background image.
centers = np.sum(pts[tri.simplices], axis=1, dtype='int')/3.0
colors = [img[y,x] for x,y in centers]
# This plots the edges of each triangle with no fill. I'd like to
# include the colors list to plot a fill for each.
plt.triplot(pts[:,0], pts[:,1], tri.simplices.copy())
plt.show()
내가 해당 삼각형의 색상이 들어있는 색상 목록을 통과 할 수있는 triplot 몇 가지 인수가 거기에있다. 적절한 삼각형을 사용하여 각 삼각형을 반복적으로 그릴 수는 있지만 더 우아하고 빠른 방법이 있다면 좋을 것입니다.