当前位置: 首页>>代码示例>>Python>>正文


Python Polygon.get_xy方法代码示例

本文整理汇总了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)
开发者ID:717524640,项目名称:matplotlib,代码行数:35,代码来源:test_patches.py

示例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)
开发者ID:morganjwilliams,项目名称:exploratory-geochemistry,代码行数:14,代码来源:classification.py


注:本文中的matplotlib.patches.Polygon.get_xy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。