本文整理汇总了Python中matplotlib.patches.Polygon.get_xy方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.get_xy方法的具体用法?Python Polygon.get_xy怎么用?Python Polygon.get_xy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.Polygon
的用法示例。
在下文中一共展示了Polygon.get_xy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Polygon_close
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_xy [as 别名]
def test_Polygon_close():
#: Github issue #1018 identified a bug in the Polygon handling
#: of the closed attribute; the path was not getting closed
#: when set_xy was used to set the vertices.
# open set of vertices:
xy = [[0, 0], [0, 1], [1, 1]]
# closed set:
xyclosed = xy + [[0, 0]]
# start with open path and close it:
p = Polygon(xy, closed=True)
assert_array_equal(p.get_xy(), xyclosed)
p.set_xy(xy)
assert_array_equal(p.get_xy(), xyclosed)
# start with closed path and open it:
p = Polygon(xyclosed, closed=False)
assert_array_equal(p.get_xy(), xy)
p.set_xy(xyclosed)
assert_array_equal(p.get_xy(), xy)
# start with open path and leave it open:
p = Polygon(xy, closed=False)
assert_array_equal(p.get_xy(), xy)
p.set_xy(xy)
assert_array_equal(p.get_xy(), xy)
# start with closed path and leave it closed:
p = Polygon(xyclosed, closed=True)
assert_array_equal(p.get_xy(), xyclosed)
p.set_xy(xyclosed)
assert_array_equal(p.get_xy(), xyclosed)
示例2: add_to_axes
# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import get_xy [as 别名]
def add_to_axes(self, ax=None, **kwargs):
polys = [(c, self.fields[c]) for c in self.fclasses if self.fields[c]['poly']]
if ax is None:
fig, ax = plt.subplots(1)
pgns = []
for c, f in polys:
label = f['names']
pg = Polygon(f['poly'], closed=True, **kwargs)
pgns.append(pg)
x, y = pg.get_xy().T
ax.annotate(c, xy=(np.nanmean(x), np.nanmean(y)))
ax.add_patch(pg)