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


Python Path.iter_segments方法代码示例

本文整理汇总了Python中matplotlib.path.Path.iter_segments方法的典型用法代码示例。如果您正苦于以下问题:Python Path.iter_segments方法的具体用法?Python Path.iter_segments怎么用?Python Path.iter_segments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.path.Path的用法示例。


在下文中一共展示了Path.iter_segments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_clipping_full

# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import iter_segments [as 别名]
def test_clipping_full():
    p = Path([[1e30, 1e30]] * 5)
    simplified = list(p.iter_segments(clip=[0, 0, 100, 100]))
    assert simplified == []

    p = Path([[50, 40], [75, 65]], [1, 2])
    simplified = list(p.iter_segments(clip=[0, 0, 100, 100]))
    assert ([(list(x), y) for x, y in simplified] ==
            [([50, 40], 1), ([75, 65], 2)])

    p = Path([[50, 40]], [1])
    simplified = list(p.iter_segments(clip=[0, 0, 100, 100]))
    assert ([(list(x), y) for x, y in simplified] ==
            [([50, 40], 1)])
开发者ID:QuLogic,项目名称:matplotlib,代码行数:16,代码来源:test_simplification.py

示例2: test_start_with_moveto

# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import iter_segments [as 别名]
def test_start_with_moveto():
    # Should be entirely clipped away to a single MOVETO
    data = b"""
ZwAAAAku+v9UAQAA+Tj6/z8CAADpQ/r/KAMAANlO+v8QBAAAyVn6//UEAAC6ZPr/2gUAAKpv+v+8
BgAAm3r6/50HAACLhfr/ewgAAHyQ+v9ZCQAAbZv6/zQKAABepvr/DgsAAE+x+v/lCwAAQLz6/7wM
AAAxx/r/kA0AACPS+v9jDgAAFN36/zQPAAAF6Pr/AxAAAPfy+v/QEAAA6f36/5wRAADbCPv/ZhIA
AMwT+/8uEwAAvh77//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PwAAa3z//zk/AABih///TD8AAFmS//9dPwAAUJ3//2w/
AABHqP//ej8AAD6z//+FPwAANb7//48/AAAsyf//lz8AACPU//+ePwAAGt///6M/AAAR6v//pj8A
AAj1//+nPwAA/////w=="""

    verts = np.frombuffer(base64.decodebytes(data), dtype='<i4')
    verts = verts.reshape((len(verts) // 2, 2))
    path = Path(verts)
    segs = path.iter_segments(transforms.IdentityTransform(),
                              clip=(0.0, 0.0, 100.0, 100.0))
    segs = list(segs)
    assert len(segs) == 1
    assert segs[0][1] == Path.MOVETO
开发者ID:QuLogic,项目名称:matplotlib,代码行数:34,代码来源:test_simplification.py

示例3: Path

# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import iter_segments [as 别名]
data = np.load(vertfilename)

verts = data['vertices']

path = Path(verts, closed = True)
print len(path)

path.should_simplify = True
path.simplify_threshold = 10.0

# <codecell>

vertices = []
codes = []
for (vertex, code) in path.iter_segments(simplify = True):
    vertices.append(vertex.tolist())
    codes.append(code)

# <codecell>

cleanpath = Path(vertices, codes)
len(cleanpath)

# <codecell>

codes[-1] = Path.CLOSEPOLY

# <codecell>

bbox = cleanpath.get_extents()
开发者ID:,项目名称:,代码行数:32,代码来源:

示例4:

# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import iter_segments [as 别名]
y = np.sin(x)

fig   = plt.figure()
ax    = fig.add_subplot(111)
line1 = ax.plot(x,y)
patch1 = patches.PathPatch(path1, facecolor='red', edgecolor = 'blue', alpha=0.3, lw=2)
patch2 = patches.PathPatch(path2, facecolor='red', edgecolor = 'blue', alpha=0.3, lw=2)
patch2_rot = patches.PathPatch(path2_rot, facecolor = 'red', edgecolor = 'blue', alpha = 0.3, lw=2)

pc = x0,y0
epatch1 = patches.Ellipse(pc, w, h, angle=0,  ec='blue', fc='blue', alpha=0.2)
epatch2 = patches.Ellipse(pc, w, h, angle=45, ec='blue', fc='blue', alpha=0.2)

epatch3 = patches.FancyBboxPatch((0,0), w, h)

for a,b in path1.iter_segments():
    print a,b

ax.add_patch(epatch1)
ax.add_patch(epatch2)
ax.add_patch(epatch3)
ax.add_patch(patch1)
ax.add_patch(patch2)
ax.add_patch(patch2_rot)
ax.set_xlim(-5,5)
ax.set_ylim(-5,5)
plt.show()


verts = [
        (0.0,0.0), # P0
开发者ID:archman,项目名称:beamline,代码行数:33,代码来源:1.py


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