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


Python patches.FancyBboxPatch方法代码示例

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


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

示例1: test1

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def test1(ax):

    # a fancy box with round corners. pad=0.1
    p_fancy = FancyBboxPatch((bb.xmin, bb.ymin),
                             abs(bb.width), abs(bb.height),
                             boxstyle="round,pad=0.1",
                             fc=(1., .8, 1.),
                             ec=(1., 0.5, 1.))

    ax.add_patch(p_fancy)

    ax.text(0.1, 0.8,
            r' boxstyle="round,pad=0.1"',
            size=10, transform=ax.transAxes)

    # draws control points for the fancy box.
    # l = p_fancy.get_path().vertices
    # ax.plot(l[:,0], l[:,1], ".")

    # draw the original bbox in black
    draw_bbox(ax, bb) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:23,代码来源:fancybox_demo.py

示例2: test3

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def test3(ax):

    # mutation_scale determine overall scale of the mutation,
    # i.e. both pad and rounding_size is scaled according to this
    # value.
    p_fancy = FancyBboxPatch((bb.xmin, bb.ymin),
                             abs(bb.width), abs(bb.height),
                             boxstyle="round,pad=0.1",
                             mutation_scale=2.,
                             fc=(1., .8, 1.),
                             ec=(1., 0.5, 1.))

    ax.add_patch(p_fancy)

    ax.text(0.1, 0.8,
            ' boxstyle="round,pad=0.1"\n mutation_scale=2',
            size=10, transform=ax.transAxes)

    # draws control points for the fancy box.
    # l = p_fancy.get_path().vertices
    # ax.plot(l[:,0], l[:,1], ".")

    draw_bbox(ax, bb) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:25,代码来源:fancybox_demo.py

示例3: __init__

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def __init__(self, child, pad=None, draw_frame=False, patch_attrs=None):
        """
        *pad* : boundary pad

        .. note::
          *pad* need to given in points and will be
          scale with the renderer dpi, while *width* and *height*
          need to be in pixels.
        """

        super(PaddedBox, self).__init__()

        self.pad = pad
        self._children = [child]

        self.patch = FancyBboxPatch(
            xy=(0.0, 0.0), width=1., height=1.,
            facecolor='w', edgecolor='k',
            mutation_scale=1,  # self.prop.get_size_in_points(),
            snap=True
            )

        self.patch.set_boxstyle("square", pad=0)

        if patch_attrs is not None:
            self.patch.update(patch_attrs)

        self._drawFrame = draw_frame 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:30,代码来源:offsetbox.py

示例4: set_bbox

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def set_bbox(self, rectprops):
        """
        Draw a bounding box around self.  rectprops are any settable
        properties for a rectangle, eg facecolor='red', alpha=0.5.

          t.set_bbox(dict(facecolor='red', alpha=0.5))

        If rectprops has "boxstyle" key. A FancyBboxPatch
        is initialized with rectprops and will be drawn. The mutation
        scale of the FancyBboxPath is set to the fontsize.

        ACCEPTS: rectangle prop dict
        """

        # The self._bbox_patch object is created only if rectprops has
        # boxstyle key. Otherwise, self._bbox will be set to the
        # rectprops and the bbox will be drawn using bbox_artist
        # function. This is to keep the backward compatibility.

        if rectprops is not None and "boxstyle" in rectprops:
            props = rectprops.copy()
            boxstyle = props.pop("boxstyle")
            bbox_transmuter = props.pop("bbox_transmuter", None)

            self._bbox_patch = FancyBboxPatch(
                                    (0., 0.),
                                    1., 1.,
                                    boxstyle=boxstyle,
                                    bbox_transmuter=bbox_transmuter,
                                    transform=mtransforms.IdentityTransform(),
                                    **props)
            self._bbox = None
        else:
            self._bbox_patch = None
            self._bbox = rectprops 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:37,代码来源:text.py

示例5: get_bbox_patch

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def get_bbox_patch(self):
        """
        Return the bbox Patch object. Returns None if the the
        FancyBboxPatch is not made.
        """
        return self._bbox_patch 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:text.py

示例6: height

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def height(self):
        shape = self.brush.style[1]
        if isinstance(self.obj, plt.Circle):
            return self.obj.radius * 2
        elif isinstance(self.obj, plt.Rectangle):
            return self.obj.get_height()
        elif isinstance(self.obj, patches.FancyBboxPatch):
            return self.obj.get_height() + 2*self.obj.get_boxstyle().pad
        elif isinstance(self.obj, (plt.Polygon, patches.PathPatch)):
            y = self.path[:,1]
            return y.max() - y.min()
        else:
            raise 
开发者ID:GiggleLiu,项目名称:viznet,代码行数:15,代码来源:edgenode.py

示例7: width

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def width(self):
        shape = self.brush.style[1]
        if isinstance(self.obj, plt.Circle):
            return self.obj.radius * 2
        elif isinstance(self.obj, plt.Rectangle):
            return self.obj.get_width()
        elif isinstance(self.obj, patches.FancyBboxPatch):
            return self.obj.get_width() + 2*self.obj.get_boxstyle().pad
        elif isinstance(self.obj, (plt.Polygon, patches.PathPatch)):
            x = self.path[:,0]
            return x.max() - x.min()
        else:
            raise 
开发者ID:GiggleLiu,项目名称:viznet,代码行数:15,代码来源:edgenode.py

示例8: rectangle

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def rectangle(xy, size, angle, roundness, **kwargs):
    '''width is relative width with respect to height.'''
    if np.ndim(size) == 0:
        size = (size, size)
    width, height = 2*size[0], 2*size[1]
    xy_ = xy[0] - width / 2., xy[1] - height / 2.
    if roundness!=0:
        pad = roundness
        c = patches.FancyBboxPatch(xy_+np.array([pad,pad]), width-pad*2, height-pad*2,
                          boxstyle=patches.BoxStyle("Round", pad=pad), **_fix(kwargs))
    else:
        c = patches.Rectangle(xy_, width, height, **_fix(kwargs))
    return [c]

##########################  Derived types  ############################# 
开发者ID:GiggleLiu,项目名称:viznet,代码行数:17,代码来源:shapes.py

示例9: draw_features

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def draw_features(features, ax=None, alpha=0.65, width=2e-5, **kwargs):
    if ax is None:
        fig, ax = plt.subplots(1)

    ellipses = []
    kwargs.setdefault("lw", 0.05)
    lw = kwargs.get("linewidth", kwargs.get("lw"))
    for feat in features:
        if feat is None:
            continue
        center = (feat.end_time + feat.start_time) / 2.
        height = feat.end_time - feat.start_time

        center_mz = feat.mz
        mz_width = center_mz * width

        ellipses.append(
            FancyBboxPatch((feat.mz - mz_width / 4., center - height / 2.), width=mz_width / 2., height=height,
                           boxstyle=mpatches.BoxStyle.Round(pad=mz_width / 2.)))

    for ell in ellipses:
        ell.set_alpha(alpha)
        ell.set_facecolor("blue")
        ell.set_edgecolor("blue")
        ell.set_linewidth(lw)
        ax.add_artist(ell)

    ax.set_xlim(
        min(features, key=lambda x: x.mz if x is not None else float('inf')).mz - 1,
        max(features, key=lambda x: x.mz if x is not None else -float('inf')).mz + 1)
    ax.set_ylim(
        min(features, key=lambda x: x.start_time if x is not None else float('inf')).start_time - 1,
        max(features, key=lambda x: x.end_time if x is not None else -float('inf')).end_time + 1)
    return ax 
开发者ID:mobiusklein,项目名称:ms_deisotope,代码行数:36,代码来源:map_viz.py

示例10: set_bbox

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def set_bbox(self, rectprops):
        """
        Draw a bounding box around self.  rectprops are any settable
        properties for a rectangle, e.g., facecolor='red', alpha=0.5.

          t.set_bbox(dict(facecolor='red', alpha=0.5))

        If rectprops has "boxstyle" key. A FancyBboxPatch
        is initialized with rectprops and will be drawn. The mutation
        scale of the FancyBboxPath is set to the fontsize.

        ACCEPTS: rectangle prop dict
        """

        # The self._bbox_patch object is created only if rectprops has
        # boxstyle key. Otherwise, self._bbox will be set to the
        # rectprops and the bbox will be drawn using bbox_artist
        # function. This is to keep the backward compatibility.

        if rectprops is not None and "boxstyle" in rectprops:
            props = rectprops.copy()
            boxstyle = props.pop("boxstyle")
            bbox_transmuter = props.pop("bbox_transmuter", None)

            self._bbox_patch = FancyBboxPatch(
                                    (0., 0.),
                                    1., 1.,
                                    boxstyle=boxstyle,
                                    bbox_transmuter=bbox_transmuter,
                                    transform=mtransforms.IdentityTransform(),
                                    **props)
            self._bbox = None
        else:
            self._bbox_patch = None
            self._bbox = rectprops

        self._update_clip_properties() 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:39,代码来源:text.py

示例11: __init__

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def __init__(self, child, pad=None, draw_frame=False, patch_attrs=None):
        """
        *pad* : boundary pad

        .. note::
          *pad* need to given in points and will be
          scale with the renderer dpi, while *width* and *height*
          need to be in pixels.
        """

        super().__init__()

        self.pad = pad
        self._children = [child]

        self.patch = FancyBboxPatch(
            xy=(0.0, 0.0), width=1., height=1.,
            facecolor='w', edgecolor='k',
            mutation_scale=1,  # self.prop.get_size_in_points(),
            snap=True
            )

        self.patch.set_boxstyle("square", pad=0)

        if patch_attrs is not None:
            self.patch.update(patch_attrs)

        self._drawFrame = draw_frame 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:30,代码来源:offsetbox.py

示例12: draw_bbox

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def draw_bbox(ax, bb):
    # boxstyle=square with pad=0, i.e. bbox itself.
    p_bbox = FancyBboxPatch((bb.xmin, bb.ymin),
                            abs(bb.width), abs(bb.height),
                            boxstyle="square,pad=0.",
                            ec="k", fc="none", zorder=10.,
                            )
    ax.add_patch(p_bbox) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:10,代码来源:fancybox_demo.py

示例13: test2

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def test2(ax):

    # bbox=round has two optional argument. pad and rounding_size.
    # They can be set during the initialization.
    p_fancy = FancyBboxPatch((bb.xmin, bb.ymin),
                             abs(bb.width), abs(bb.height),
                             boxstyle="round,pad=0.1",
                             fc=(1., .8, 1.),
                             ec=(1., 0.5, 1.))

    ax.add_patch(p_fancy)

    # boxstyle and its argument can be later modified with
    # set_boxstyle method. Note that the old attributes are simply
    # forgotten even if the boxstyle name is same.

    p_fancy.set_boxstyle("round,pad=0.1, rounding_size=0.2")
    # or
    # p_fancy.set_boxstyle("round", pad=0.1, rounding_size=0.2)

    ax.text(0.1, 0.8,
            ' boxstyle="round,pad=0.1\n rounding_size=0.2"',
            size=10, transform=ax.transAxes)

    # draws control points for the fancy box.
    # l = p_fancy.get_path().vertices
    # ax.plot(l[:,0], l[:,1], ".")

    draw_bbox(ax, bb) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:31,代码来源:fancybox_demo.py

示例14: test4

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def test4(ax):

    # When the aspect ratio of the axes is not 1, the fancy box may
    # not be what you expected (green)

    p_fancy = FancyBboxPatch((bb.xmin, bb.ymin),
                             abs(bb.width), abs(bb.height),
                             boxstyle="round,pad=0.2",
                             fc="none",
                             ec=(0., .5, 0.), zorder=4)

    ax.add_patch(p_fancy)

    # You can compensate this by setting the mutation_aspect (pink).
    p_fancy = FancyBboxPatch((bb.xmin, bb.ymin),
                             abs(bb.width), abs(bb.height),
                             boxstyle="round,pad=0.3",
                             mutation_aspect=.5,
                             fc=(1., 0.8, 1.),
                             ec=(1., 0.5, 1.))

    ax.add_patch(p_fancy)

    ax.text(0.1, 0.8,
            ' boxstyle="round,pad=0.3"\n mutation_aspect=.5',
            size=10, transform=ax.transAxes)

    draw_bbox(ax, bb) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:30,代码来源:fancybox_demo.py

示例15: __init__

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import FancyBboxPatch [as 别名]
def __init__(self,
                 x=0, y=0, text='',
                 color=None,           # defaults to rc params
                 verticalalignment='baseline',
                 horizontalalignment='left',
                 multialignment=None,
                 fontproperties=None,  # defaults to FontProperties()
                 rotation=None,
                 linespacing=None,
                 rotation_mode=None,
                 **kwargs
                 ):
        """
        Create a :class:`~matplotlib.text.Text` instance at *x*, *y*
        with string *text*.

        Valid kwargs are
        %(Text)s
        """

        Artist.__init__(self)
        self._x, self._y = x, y

        if color is None:
            color = rcParams['text.color']
        if fontproperties is None:
            fontproperties = FontProperties()
        elif is_string_like(fontproperties):
            fontproperties = FontProperties(fontproperties)

        self.set_text(text)
        self.set_color(color)
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._multialignment = multialignment
        self._rotation = rotation
        self._fontproperties = fontproperties
        self._bbox = None
        self._bbox_patch = None  # a FancyBboxPatch instance
        self._renderer = None
        if linespacing is None:
            linespacing = 1.2   # Maybe use rcParam later.
        self._linespacing = linespacing
        self.set_rotation_mode(rotation_mode)
        self.update(kwargs)
        #self.set_bbox(dict(pad=0)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:48,代码来源:text.py


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