当前位置: 首页>>代码示例>>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;未经允许,请勿转载。