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


Python Bbox.union方法代码示例

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


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

示例1: get_tightbbox

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def get_tightbbox(self, renderer, *args, **kwargs):

        # FIXME: we should determine what to do with the extra arguments here.
        # Note that the expected signature of this method is different in
        # Matplotlib 3.x compared to 2.x.

        if not self.get_visible():
            return

        bb = [b for b in self._bboxes if b and (b.width != 0 or b.height != 0)]

        if bb:
            _bbox = Bbox.union(bb)
            return _bbox
        else:
            return self.get_window_extent(renderer) 
开发者ID:holzschu,项目名称:Carnets,代码行数:18,代码来源:core.py

示例2: get_tightbbox

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def get_tightbbox(self, renderer, call_axes_locator=True):

        bbs = [ax.get_tightbbox(renderer, call_axes_locator) \
               for ax in self.parasites]
        get_tightbbox = self._get_base_axes_attr("get_tightbbox")
        bbs.append(get_tightbbox(self, renderer, call_axes_locator))

        _bbox = Bbox.union([b for b in bbs if b.width!=0 or b.height!=0])

        return _bbox 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:12,代码来源:parasite_axes.py

示例3: get_window_extent

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def get_window_extent(self, renderer=None):
        '''
        Return a :class:`~matplotlib.transforms.Bbox` object bounding
        the text and arrow annotation, in display units.

        *renderer* defaults to the _renderer attribute of the text
        object.  This is not assigned until the first execution of
        :meth:`draw`, so you must use this kwarg if you want
        to call :meth:`get_window_extent` prior to the first
        :meth:`draw`.  For getting web page regions, it is
        simpler to call the method after saving the figure. The
        *dpi* used defaults to self.figure.dpi; the renderer dpi is
        irrelevant.

        '''
        if not self.get_visible():
            return Bbox.unit()
        arrow = self.arrow
        arrow_patch = self.arrow_patch

        text_bbox = Text.get_window_extent(self, renderer=renderer)
        bboxes = [text_bbox]

        if self.arrow is not None:
            bboxes.append(arrow.get_window_extent(renderer=renderer))
        elif self.arrow_patch is not None:
            bboxes.append(arrow_patch.get_window_extent(renderer=renderer))

        return Bbox.union(bboxes) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:31,代码来源:text.py

示例4: test_text_with_arrow_annotation_get_window_extent

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def test_text_with_arrow_annotation_get_window_extent():
    headwidth = 21
    fig, ax = plt.subplots(dpi=100)
    txt = ax.text(s='test', x=0, y=0)
    ann = ax.annotate('test',
        xy=(0.0, 50.0),
        xytext=(50.0, 50.0), xycoords='figure pixels',
        arrowprops={
            'facecolor': 'black', 'width': 2,
            'headwidth': headwidth, 'shrink': 0.0})

    plt.draw()
    renderer = fig.canvas.renderer
    # bounding box of text
    text_bbox = txt.get_window_extent(renderer=renderer)
    # bounding box of annotation (text + arrow)
    bbox = ann.get_window_extent(renderer=renderer)
    # bounding box of arrow
    arrow_bbox = ann.arrow.get_window_extent(renderer)
    # bounding box of annotation text
    ann_txt_bbox = Text.get_window_extent(ann)

    # make sure annotation with in 50 px wider than
    # just the text
    eq_(bbox.width, text_bbox.width + 50.0)
    # make sure the annotation text bounding box is same size
    # as the bounding box of the same string as a Text object
    eq_(ann_txt_bbox.height, text_bbox.height)
    eq_(ann_txt_bbox.width, text_bbox.width)
    # compute the expected bounding box of arrow + text
    expected_bbox = Bbox.union([ann_txt_bbox, arrow_bbox])
    assert_almost_equal(bbox.height, expected_bbox.height) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:34,代码来源:test_text.py

示例5: get_tightbbox

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def get_tightbbox(self, renderer, call_axes_locator=True):
        bb0 = super().get_tightbbox(renderer, call_axes_locator)
        if not self._axisline_on:
            return bb0
        bb = [bb0] + [axisline.get_tightbbox(renderer)
                      for axisline in self._axislines.values()
                      if axisline.get_visible()]
        bbox = Bbox.union([b for b in bb if b and (b.width!=0 or b.height!=0)])
        return bbox 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:axislines.py

示例6: get_tightbbox

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def get_tightbbox(self, renderer, call_axes_locator=True):
        bbs = [ax.get_tightbbox(renderer, call_axes_locator)
               for ax in self.parasites]
        bbs.append(super().get_tightbbox(renderer, call_axes_locator))
        return Bbox.union([b for b in bbs if b.width != 0 or b.height != 0]) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:7,代码来源:parasite_axes.py

示例7: get_tight_bbox

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def get_tight_bbox(fig, bbox_extra_artists=[], pad=None):
    """
    Compute a tight bounding box around all the artists in the figure.
    """
    renderer = fig.canvas.get_renderer()
    bbox_inches = fig.get_tightbbox(renderer)
    bbox_artists = bbox_extra_artists[:]
    bbox_artists += fig.get_default_bbox_extra_artists()
    bbox_filtered = []
    for a in bbox_artists:
        bbox = a.get_window_extent(renderer)
        if isinstance(bbox, tuple):
            continue
        if a.get_clip_on():
            clip_box = a.get_clip_box()
            if clip_box is not None:
                bbox = Bbox.intersection(bbox, clip_box)
            clip_path = a.get_clip_path()
            if clip_path is not None and bbox is not None:
                clip_path = clip_path.get_fully_transformed_path()
                bbox = Bbox.intersection(bbox,
                                         clip_path.get_extents())
        if bbox is not None and (bbox.width != 0 or
                                 bbox.height != 0):
            bbox_filtered.append(bbox)
    if bbox_filtered:
        _bbox = Bbox.union(bbox_filtered)
        trans = Affine2D().scale(1.0 / fig.dpi)
        bbox_extra = TransformedBbox(_bbox, trans)
        bbox_inches = Bbox.union([bbox_inches, bbox_extra])
    return bbox_inches.padded(pad) if pad else bbox_inches 
开发者ID:holoviz,项目名称:holoviews,代码行数:33,代码来源:util.py

示例8: get_tightbbox

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def get_tightbbox(self, renderer, call_axes_locator=True,
                      bbox_extra_artists=None):
        bbs = [ax.get_tightbbox(renderer, call_axes_locator=call_axes_locator)
               for ax in self.parasites]
        bbs.append(super().get_tightbbox(renderer,
                call_axes_locator=call_axes_locator,
                bbox_extra_artists=bbox_extra_artists))
        return Bbox.union([b for b in bbs if b.width != 0 or b.height != 0]) 
开发者ID:boris-kz,项目名称:CogAlg,代码行数:10,代码来源:parasite_axes.py

示例9: full_extent

# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import union [as 别名]
def full_extent(ax, pad=0.0):
    from matplotlib.transforms import Bbox
    """Get the full extent of an axes, including axes labels, tick labels, and titles."""
    # For text objects, we need to draw the figure first, otherwise the extents
    # are undefined.
    ax.figure.canvas.draw()
    items = [ax, *ax.texts]
    bbox = Bbox.union([item.get_window_extent() for item in items])

    return bbox.expanded(1.0 + pad, 1.0 + pad)

# @utils.ignore_warnings 
开发者ID:pelednoam,项目名称:mmvt,代码行数:14,代码来源:anatomy.py


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