本文整理汇总了Python中matplotlib.patches.Polygon.set_array方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.set_array方法的具体用法?Python Polygon.set_array怎么用?Python Polygon.set_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Polygon
的用法示例。
在下文中一共展示了Polygon.set_array方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getGuards
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import set_array [as 别名]
def getGuards(polygon_no):
positions = []
data = triangulate(polygons[str(polygon_no)])
vertices = data['tri']['vertices']
colours = get_colour(data)
min_c = get_min_colour(colours)
stars = get_stars(data)
star_polygons = star_poly_array(stars, vertices)
# print(stars)
# print(star_polygons)
# print(vertices)
# print(min_c)
adj = adj_matrix(data)
# print(adj[24])
# print(adj[33])
# print(adj[60])
# pdb.set_trace()
def compare(plt, A, B):
ax1 = plt.subplot(121, aspect='equal')
triangle.plot.plot(ax1, **A)
ax2 = plt.subplot(122, sharex=ax1, sharey=ax1)
triangle.plot.plot(ax2, **B)
return (ax1, ax2)
ax1, ax2 = compare(plt, data['original'], data['tri'])
# Colour polygons
patches = []
for polygon in star_polygons:
p = Polygon(polygon, True)
patches.append(p)
p = PatchCollection(patches, cmap=matplotlib.cm.jet)
plt.gca().add_collection(p)
# Label vertex indices
for i, v in enumerate(vertices):
ax1.text(v[0], v[1], str(i))
for c, v in zip(colours, vertices):
if c == min_c:
positions.append(v.tolist())
plt.annotate(c, xy=tuple(v), color='darkblue')
# positions = starise.kernels(stars, vertices)
# Plot kernel points
ax1.plot(*zip(*positions), marker='^', color='g', ls='')
# Set colours and config for plot
colors = range(0,1000, int(1000/len(patches)))
p.set_array(np.array(colors))
plt.subplots_adjust(left=0, bottom=0, right=1, top=1,
wspace=0, hspace=0)
plt.show()
# pdb.set_trace()
return positions