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


Python Rectangle.get_verts方法代码示例

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


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

示例1: plotCov

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import get_verts [as 别名]
def plotCov(cov, refl, point, map, grid_spacing, file_name, roi=50, normalize=(-1, 1)):
    pylab.figure(figsize=(10, 8))

    pt_z, pt_lat, pt_lon = point
    pt_x, pt_y = map(pt_lon, pt_lat)

    dx, dy = grid_spacing
    nx, ny = cov.shape

    xs, ys = np.meshgrid(dx * np.arange(nx), dy * np.arange(ny))

    lbound, ubound = normalize
    dbound = (ubound - lbound) / 20.
    levels = np.arange(lbound, ubound + dbound, dbound)

    map.contourf(xs, ys, cov, levels=levels)
    pylab.colorbar()
    pylab.contour(xs, ys, refl, levels=[20., 40.], colors='k')

    pylab.plot(pt_x, pt_y, 'ko')
    roi_circle = CirclePolygon((pt_x, pt_y), roi * 1000., resolution=40, ec='k', fc='none')
    axes_box = Rectangle((0, 0), 1, 1, ec='w', fc='w', alpha=0.5, clip_path=roi_circle, transform=(pylab.gca().transAxes + pylab.gca().transData.inverted()))

    path_codes = [ Path.MOVETO ] + (axes_box.get_verts().shape[0] - 1) * [ Path.LINETO ] + [ Path.MOVETO ] + (roi_circle.get_verts().shape[0] - 1) * [ Path.LINETO ]
    path_verts = np.concatenate((axes_box.get_verts(), roi_circle.get_verts()[::-1]))

    mask_path = Path(path_verts, path_codes)
    mask_patch = PathPatch(mask_path, fc='w', ec='w', alpha=0.7)
    pylab.gca().add_patch(mask_patch)

    map.drawcoastlines(linewidth=1.5)
    map.drawcountries(linewidth=1.5)
    map.drawstates(linewidth=1.0)
    if not hasattr(map, 'counties'):
        map.readshapefile('countyp020', 'counties', linewidth=0.5)
    else:
        for county, data in izip(map.counties_info, map.counties):
            if county['STATE'] in ['NE', 'WY', 'CO']:
                pylab.gca().add_patch(Polygon(data, ec='k', fc='none', linewidth=0.5))

    pylab.savefig(file_name)
    pylab.close()
    return
开发者ID:tsupinie,项目名称:research,代码行数:45,代码来源:cov.py

示例2: test_rotate_rect

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import get_verts [as 别名]
def test_rotate_rect():
    loc = np.asarray([1.0, 2.0])
    width = 2
    height = 3
    angle = 30.0

    # A rotated rectangle
    rect1 = Rectangle(loc, width, height, angle=angle)

    # A non-rotated rectangle
    rect2 = Rectangle(loc, width, height)

    # Set up an explicit rotation matrix (in radians)
    angle_rad = np.pi * angle / 180.0
    rotation_matrix = np.array([[np.cos(angle_rad), -np.sin(angle_rad)], [np.sin(angle_rad), np.cos(angle_rad)]])

    # Translate to origin, rotate each vertex, and then translate back
    new_verts = np.inner(rotation_matrix, rect2.get_verts() - loc).T + loc

    # They should be the same
    assert_almost_equal(rect1.get_verts(), new_verts)
开发者ID:KevKeating,项目名称:matplotlib,代码行数:23,代码来源:test_patches.py


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