本文整理汇总了Python中matplotlib.path.Path.unit_regular_polygon方法的典型用法代码示例。如果您正苦于以下问题:Python Path.unit_regular_polygon方法的具体用法?Python Path.unit_regular_polygon怎么用?Python Path.unit_regular_polygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.path.Path
的用法示例。
在下文中一共展示了Path.unit_regular_polygon方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import unit_regular_polygon [as 别名]
def __init__(self, xy, numVertices, radius=5, orientation=0,
**kwargs):
"""
Constructor arguments:
*xy*
A length 2 tuple (*x*, *y*) of the center.
*numVertices*
the number of vertices.
*radius*
The distance from the center to each of the vertices.
*orientation*
rotates the polygon (in radians).
Valid kwargs are:
%(Patch)s
"""
self._xy = xy
self._numVertices = numVertices
self._orientation = orientation
self._radius = radius
self._path = Path.unit_regular_polygon(numVertices)
self._poly_transform = transforms.Affine2D()
self._update_transform()
Patch.__init__(self, **kwargs)
示例2: draw_generic
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import unit_regular_polygon [as 别名]
def draw_generic(ax, x, y, name, n_points=6, scale=0.1):
unit_polygon = Path.unit_regular_polygon(n_points)
path = Path(unit_polygon.vertices * scale, unit_polygon.codes)
trans = matplotlib.transforms.Affine2D().translate(x, y)
t_path = path.transformed(trans)
name = TextPath((x - (0.35 * scale), y), s=name, size=2 * scale * .25)
patch = patches.PathPatch(t_path, facecolor="white", lw=line_weight, zorder=2)
a = ax.add_patch(patch)
patch = patches.PathPatch(name, lw=line_weight, zorder=2)
s = ax.add_patch(patch)
ma = MonosaccharidePatch(saccharide_shape=(a,), saccharide_label=(s,))
return ma
示例3: _gen_axes_spines
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import unit_regular_polygon [as 别名]
def _gen_axes_spines(self):
if frame == 'circle':
return super()._gen_axes_spines()
elif frame == 'polygon':
# spine_type must be 'left'/'right'/'top'/'bottom'/'circle'.
spine = Spine(axes=self,
spine_type='circle',
path=Path.unit_regular_polygon(num_vars))
# unit_regular_polygon gives a polygon of radius 1 centered at
# (0, 0) but we want a polygon of radius 0.5 centered at (0.5,
# 0.5) in axes coordinates.
spine.set_transform(Affine2D().scale(.5).translate(.5, .5)
+ self.transAxes)
return {'polar': spine}
else:
raise ValueError("unknown value for 'frame': %s" % frame)
示例4: __init__
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import unit_regular_polygon [as 别名]
def __init__(self, xy, numVertices, radius=5, orientation=0, **kwargs):
"""
xy is a length 2 tuple (the center)
numVertices is the number of vertices.
radius is the distance from the center to each of the vertices.
orientation is in radians and rotates the polygon.
Valid kwargs are:
%(Patch)s
"""
self._xy = xy
self._numVertices = numVertices
self._orientation = orientation
self._radius = radius
self._path = Path.unit_regular_polygon(numVertices)
self._poly_transform = transforms.Affine2D()
self._update_transform()
Patch.__init__(self, **kwargs)
示例5: _set_numvertices
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import unit_regular_polygon [as 别名]
def _set_numvertices(self, numVertices):
self._numVertices = numVertices
self._path = Path.unit_regular_polygon(numVertices)
示例6: return
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import unit_regular_polygon [as 别名]
# return (a,)
draw_map[ResidueShape.square] = draw_square
unit_rectangle = Path.unit_rectangle()
def draw_triangle(ax, x, y, color, scale=0.1):
path = Path(unit_triangle.vertices * scale, unit_triangle.codes)
trans = matplotlib.transforms.Affine2D().translate(x, y).rotate_deg_around(x, y, -90)
t_path = path.transformed(trans)
patch = patches.PathPatch(t_path, facecolor=color.value, lw=line_weight, zorder=2)
a = ax.add_patch(patch)
ma = MonosaccharidePatch(saccharide_shape=(a,))
return ma
# return (a,)
draw_map[ResidueShape.triangle] = draw_triangle
unit_triangle = Path.unit_regular_polygon(3)
def draw_bisected_square(ax, x, y, color, scale=0.1):
lower_verts = (np.array([
(0., 0.),
(1.0, 0),
(0, 1.0),
(0, 0),
(0., 0.),
]) - 0.5) / 5
upper_verts = (np.array([
(1., 1.),
(1.0, 0),
(0, 1.0),