當前位置: 首頁>>代碼示例>>Python>>正文


Python Bbox.from_bounds方法代碼示例

本文整理匯總了Python中matplotlib.transforms.Bbox.from_bounds方法的典型用法代碼示例。如果您正苦於以下問題:Python Bbox.from_bounds方法的具體用法?Python Bbox.from_bounds怎麽用?Python Bbox.from_bounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.transforms.Bbox的用法示例。


在下文中一共展示了Bbox.from_bounds方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ylow

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def ylow(ax=None, ylow=None):
    """
    Set lower y limit to 0 if not data/errors go lower.
    Or set a specific value
    """
    if ax is None:
        ax = plt.gca()

    if ylow is None:
        # Check full figsize below 0
        bbox = Bbox.from_bounds(
            0, 0, ax.get_window_extent().width, -ax.get_window_extent().height
        )
        if overlap(ax, bbox) == 0:
            ax.set_ylim(0, None)
        else:
            ydata = overlap(ax, bbox, get_vertices=True)[1][:, 1]
            ax.set_ylim(np.min([np.min(ydata), ax.get_ylim()[0]]), None)

    else:
        ax.set_ylim(0, ax.get_ylim()[-1])

    return ax 
開發者ID:scikit-hep,項目名稱:mplhep,代碼行數:25,代碼來源:plot.py

示例2: set_bbox_to_anchor

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def set_bbox_to_anchor(self, bbox, transform=None):
        """
        set the bbox that the child will be anchored.

        *bbox* can be a Bbox instance, a list of [left, bottom, width,
        height], or a list of [left, bottom] where the width and
        height will be assumed to be zero. The bbox will be
        transformed to display coordinate by the given transform.
        """
        if bbox is None or isinstance(bbox, BboxBase):
            self._bbox_to_anchor = bbox
        else:
            try:
                l = len(bbox)
            except TypeError:
                raise ValueError("Invalid argument for bbox : %s" % str(bbox))

            if l == 2:
                bbox = [bbox[0], bbox[1], 0, 0]

            self._bbox_to_anchor = Bbox.from_bounds(*bbox)

        self._bbox_to_anchor_transform = transform 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:25,代碼來源:offsetbox.py

示例3: _update_offset_func

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def _update_offset_func(self, renderer, fontsize=None):
        """
        Update the offset func which depends on the dpi of the
        renderer (because of the padding).
        """
        if fontsize is None:
            fontsize = renderer.points_to_pixels(
                            self.prop.get_size_in_points())

        def _offset(w, h, xd, yd, renderer, fontsize=fontsize, self=self):
            bbox = Bbox.from_bounds(0, 0, w, h)
            borderpad = self.borderpad * fontsize
            bbox_to_anchor = self.get_bbox_to_anchor()

            x0, y0 = self._get_anchored_bbox(self.loc,
                                             bbox,
                                             bbox_to_anchor,
                                             borderpad)
            return x0 + xd, y0 + yd

        self.set_offset(_offset) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:offsetbox.py

示例4: adjust_bbox_png

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def adjust_bbox_png(fig, bbox_inches):
    """
    adjust_bbox for png (Agg) format
    """

    tr = fig.dpi_scale_trans

    _bbox = TransformedBbox(bbox_inches,
                            tr)
    x0, y0 = _bbox.x0, _bbox.y0
    fig.bbox_inches = Bbox.from_bounds(0, 0,
                                       bbox_inches.width,
                                       bbox_inches.height)

    x0, y0 = _bbox.x0, _bbox.y0
    w1, h1 = fig.bbox.width, fig.bbox.height
    fig.transFigure._boxout = Bbox.from_bounds(-x0, -y0,
                                                       w1, h1)
    fig.transFigure.invalidate()

    fig.bbox = TransformedBbox(fig.bbox_inches, tr)

    fig.patch.set_bounds(x0 / w1, y0 / h1,
                         fig.bbox.width / w1, fig.bbox.height / h1) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:tight_bbox.py

示例5: __init__

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def __init__(self, width, height, dpi):
        if __debug__: verbose.report('RendererAgg.__init__', 'debug-annoying')
        RendererBase.__init__(self)
        self.texd = maxdict(50)  # a cache of tex image rasters

        self.dpi = dpi
        self.width = width
        self.height = height
        if __debug__: verbose.report('RendererAgg.__init__ width=%s, height=%s'%(width, height), 'debug-annoying')
        self._renderer = _RendererAgg(int(width), int(height), dpi, debug=False)
        self._filter_renderers = []

        if __debug__: verbose.report('RendererAgg.__init__ _RendererAgg done',
                                     'debug-annoying')

        self._update_methods()
        self.mathtext_parser = MathTextParser('Agg')

        self.bbox = Bbox.from_bounds(0, 0, self.width, self.height)
        if __debug__: verbose.report('RendererAgg.__init__ done',
                                     'debug-annoying') 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:23,代碼來源:backend_agg.py

示例6: __call__

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def __call__(self, axes, renderer):
        """
        Return the adjusted position of the axes
        """
        bbox0 = self.get_original_position(axes, renderer)
        bbox = bbox0

        x1, y1, w, h = bbox.bounds
        extesion_fraction = self.extesion_fraction
        dw, dh = w*extesion_fraction, h*extesion_fraction

        if self.extend in ["min", "both"]:
            if self.orientation == "horizontal":
                x1 = x1 + dw
            else:
                y1 = y1+dh

        if self.extend in ["max", "both"]:
            if self.orientation == "horizontal":
                w = w-2*dw
            else:
                h = h-2*dh

        return Bbox.from_bounds(x1, y1, w, h) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:colorbar.py

示例7: connect_bbox

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def connect_bbox(bbox1, bbox2, loc1, loc2=None):
       if isinstance(bbox1, Rectangle):
          transform = bbox1.get_transfrom()
          bbox1 = Bbox.from_bounds(0, 0, 1, 1)
          bbox1 = TransformedBbox(bbox1, transform)

       if isinstance(bbox2, Rectangle):
          transform = bbox2.get_transform()
          bbox2 = Bbox.from_bounds(0, 0, 1, 1)
          bbox2 = TransformedBbox(bbox2, transform)

       if loc2 is None:
          loc2 = loc1

       x1, y1 = BboxConnector.get_bbox_edge_pos(bbox1, loc1)
       x2, y2 = BboxConnector.get_bbox_edge_pos(bbox2, loc2)

       verts = [[x1, y1], [x2,y2]]
       #Path()

       codes = [Path.MOVETO, Path.LINETO]

       return Path(verts, codes) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:25,代碼來源:inset_locator.py

示例8: set_bbox_to_anchor

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def set_bbox_to_anchor(self, bbox, transform=None):
        """
        set the bbox that the child will be anchored.

        *bbox* can be a Bbox instance, a list of [left, bottom, width,
        height], or a list of [left, bottom] where the width and
        height will be assumed to be zero. The bbox will be
        transformed to display coordinate by the given transform.
        """
        if bbox is None or isinstance(bbox, BboxBase):
            self._bbox_to_anchor = bbox
        else:
            try:
                l = len(bbox)
            except TypeError:
                raise ValueError("Invalid argument for bbox : %s" % str(bbox))

            if l == 2:
                bbox = [bbox[0], bbox[1], 0, 0]

            self._bbox_to_anchor = Bbox.from_bounds(*bbox)

        self._bbox_to_anchor_transform = transform
        self.stale = True 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:26,代碼來源:offsetbox.py

示例9: _findoffset

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def _findoffset(self, width, height, xdescent, ydescent, renderer):
        "Helper function to locate the legend."

        if self._loc == 0:  # "best".
            x, y = self._find_best_position(width, height, renderer)
        elif self._loc in Legend.codes.values():  # Fixed location.
            bbox = Bbox.from_bounds(0, 0, width, height)
            x, y = self._get_anchored_bbox(self._loc, bbox,
                                           self.get_bbox_to_anchor(),
                                           renderer)
        else:  # Axes or figure coordinates.
            fx, fy = self._loc
            bbox = self.get_bbox_to_anchor()
            x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy

        return x + xdescent, y + ydescent 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:18,代碼來源:legend.py

示例10: get_size

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def get_size(self, renderer):
        xrel, xabs = axes_size.AddList(self.xsizes).get_size(renderer)
        yrel, yabs = axes_size.AddList(self.ysizes).get_size(renderer)
        bb = Bbox.from_bounds(*self.div.get_position()).transformed(
            self.div._fig.transFigure
        )
        w = bb.width / self.div._fig.dpi - xabs
        h = bb.height / self.div._fig.dpi - yabs
        return 0, min([w, h]) 
開發者ID:scikit-hep,項目名稱:mplhep,代碼行數:11,代碼來源:plot.py

示例11: get_window_extent

# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import from_bounds [as 別名]
def get_window_extent(self, renderer):
        '''
        get the bounding box in display space.
        '''
        w, h, xd, yd, offsets = self.get_extent_offsets(renderer)
        px, py = self.get_offset(w, h, xd, yd, renderer)
        return mtransforms.Bbox.from_bounds(px - xd, py - yd, w, h) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:9,代碼來源:offsetbox.py


注:本文中的matplotlib.transforms.Bbox.from_bounds方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。