當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。