我想改变这些多边形的边线的alpha值,而不依赖于matplotlib中的面片Polygon。我想让边线的alpha值大于多边形的面片。面片要超出边线,如何将面片完美地贴合在边线上,这样它就不会超出多边形。
代码如下:
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Polygon
from scipy.spatial import ConvexHull
hull = ConvexHull(points)
# plt.plot(points[:,0], points[:,1], 'o')
cent = np.mean(points, 0)
pts = []
for pt in points[hull.simplices]:
pts.append(pt[0].tolist())
pts.append(pt[1].tolist())
pts.sort(key=lambda p: np.arctan2(p[1] - cent[1],
p[0] - cent[0]))
pts = pts[0::2] # Deleting duplicates
pts.insert(len(pts), pts[0])
k = 0.4
poly = Polygon(k*(np.array(pts)- cent) + cent,fill=True,closed=True,
facecolor=color, alpha=0.2,edgecolor=color,linewidth=7)
plt.gca().add_patch(poly)
plt.show()
输出在这里:
1条答案
按热度按时间dddzy1tm1#
我想你可能需要把它们分开画-基本上是:
给出这种外观:x1c 0d1x