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


Python transforms.Bbox类代码示例

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


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

示例1: get_window_extent

 def get_window_extent(self, renderer):
     bbox = Bbox([[0, 0], [0, 0]])
     trans_data_to_xy = self.get_transform().transform
     bbox.update_from_data_xy(trans_data_to_xy(self.get_xydata()), ignore=True)
     # correct for marker size, if any
     if self._marker:
         ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5
         bbox = bbox.padded(ms)
     return bbox
开发者ID:mgiuca-google,项目名称:matplotlib,代码行数:9,代码来源:lines.py

示例2: get_path_collection_extents

def get_path_collection_extents(
        master_transform, paths, transforms, offsets, offset_transform):
    """
    Given a sequence of :class:`Path` objects,
    :class:`~matplotlib.transforms.Transform` objects and offsets, as
    found in a :class:`~matplotlib.collections.PathCollection`,
    returns the bounding box that encapsulates all of them.

    *master_transform* is a global transformation to apply to all paths

    *paths* is a sequence of :class:`Path` instances.

    *transforms* is a sequence of
    :class:`~matplotlib.transforms.Affine2D` instances.

    *offsets* is a sequence of (x, y) offsets (or an Nx2 array)

    *offset_transform* is a :class:`~matplotlib.transforms.Affine2D`
    to apply to the offsets before applying the offset to the path.

    The way that *paths*, *transforms* and *offsets* are combined
    follows the same method as for collections.  Each is iterated over
    independently, so if you have 3 paths, 2 transforms and 1 offset,
    their combinations are as follows:

        (A, A, A), (B, B, A), (C, A, A)
    """
    from transforms import Bbox
    if len(paths) == 0:
        raise ValueError("No paths provided")
    return Bbox.from_extents(*_get_path_collection_extents(
        master_transform, paths, transforms, offsets, offset_transform))
开发者ID:AmitAronovitch,项目名称:matplotlib,代码行数:32,代码来源:path.py

示例3: get_window_extent

 def get_window_extent(self, renderer):
     bbox = Bbox.unit()
     bbox.update_from_data_xy(self.get_transform().transform(self.get_xydata()), ignore=True)
     # correct for marker size, if any
     if self._marker is not None:
         ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5
         bbox = bbox.padded(ms)
     return bbox
开发者ID:Einstein-NTE,项目名称:einstein,代码行数:8,代码来源:lines.py

示例4: get_path_collection_extents

def get_path_collection_extents(*args):
    """
    Given a sequence of :class:`Path` objects, returns the bounding
    box that encapsulates all of them.
    """
    from transforms import Bbox
    if len(args[1]) == 0:
        raise ValueError("No paths provided")
    return Bbox.from_extents(*_get_path_collection_extents(*args))
开发者ID:zoccolan,项目名称:eyetracker,代码行数:9,代码来源:path.py

示例5: set_clip_path

    def set_clip_path(self, path, transform=None):
        """
        Set the artist's clip path, which may be:

          * a :class:`~matplotlib.patches.Patch` (or subclass) instance

          * a :class:`~matplotlib.path.Path` instance, in which case
             an optional :class:`~matplotlib.transforms.Transform`
             instance may be provided, which will be applied to the
             path before using it for clipping.

          * *None*, to remove the clipping path

        For efficiency, if the path happens to be an axis-aligned
        rectangle, this method will set the clipping box to the
        corresponding rectangle and set the clipping path to *None*.

        ACCEPTS: [ (:class:`~matplotlib.path.Path`,
        :class:`~matplotlib.transforms.Transform`) |
        :class:`~matplotlib.patches.Patch` | None ]
        """
        from matplotlib.patches import Patch, Rectangle

        success = False
        if transform is None:
            if isinstance(path, Rectangle):
                self.clipbox = TransformedBbox(Bbox.unit(),
                                              path.get_transform())
                self._clippath = None
                success = True
            elif isinstance(path, Patch):
                self._clippath = TransformedPath(
                    path.get_path(),
                    path.get_transform())
                success = True
            elif isinstance(path, tuple):
                path, transform = path

        if path is None:
            self._clippath = None
            success = True
        elif isinstance(path, Path):
            self._clippath = TransformedPath(path, transform)
            success = True
        elif isinstance(path, TransformedPath):
            self._clippath = path
            success = True

        if not success:
            print(type(path), type(transform))
            raise TypeError("Invalid arguments to set_clip_path")

        self.pchanged()
开发者ID:BrenBarn,项目名称:matplotlib,代码行数:53,代码来源:artist.py

示例6: get_paths_extents

def get_paths_extents(paths, transforms=[]):
    """
    Given a sequence of :class:`Path` objects and optional
    :class:`~matplotlib.transforms.Transform` objects, returns the
    bounding box that encapsulates all of them.

    *paths* is a sequence of :class:`Path` instances.

    *transforms* is an optional sequence of
    :class:`~matplotlib.transforms.Affine2D` instances to apply to
    each path.
    """
    from transforms import Bbox, Affine2D
    if len(paths) == 0:
        raise ValueError("No paths provided")
    return Bbox.from_extents(*_get_path_collection_extents(
        Affine2D(), paths, transforms, [], Affine2D()))
开发者ID:AmitAronovitch,项目名称:matplotlib,代码行数:17,代码来源:path.py

示例7: contains

    def contains(self, mouseevent):
        """Test whether the mouse event occurred in the table.

        Returns T/F, {}
        """
        if callable(self._contains):
            return self._contains(self, mouseevent)

        # TODO: Return index of the cell containing the cursor so that the user
        # doesn't have to bind to each one individually.
        if self._cachedRenderer is not None:
            boxes = [self._cells[pos].get_window_extent(self._cachedRenderer)
                 for pos in self._cells.iterkeys()
                 if pos[0] >= 0 and pos[1] >= 0]
            bbox = Bbox.union(boxes)
            return bbox.contains(mouseevent.x, mouseevent.y), {}
        else:
            return False, {}
开发者ID:Black-Milk,项目名称:matplotlib,代码行数:18,代码来源:table.py

示例8: Figure

class Figure(Artist):

    def __str__(self):
        return "Figure(%gx%g)"%(self.figwidth.get(),self.figheight.get())

    def __init__(self,
                 figsize   = None,  # defaults to rc figure.figsize
                 dpi       = None,  # defaults to rc figure.dpi
                 facecolor = None,  # defaults to rc figure.facecolor
                 edgecolor = None,  # defaults to rc figure.edgecolor
                 linewidth = 1.0,   # the default linewidth of the frame
                 frameon = True,    # whether or not to draw the figure frame
                 subplotpars = None, # default to rc
                 ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)

        if figsize is None  : figsize   = rcParams['figure.figsize']
        if dpi is None      : dpi       = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point( Value(0), Value(0) )
        self.ur = Point( self.figwidth*self.dpi,
                         self.figheight*self.dpi )
        self.bbox = Bbox(self.ll, self.ur)

        self.frameon = frameon

        self.transFigure = get_bbox_transform( unit_bbox(), self.bbox)



        self.figurePatch = Rectangle(
            xy=(0,0), width=1, height=1,
            facecolor=facecolor, edgecolor=edgecolor,
            linewidth=linewidth,
            )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self._axstack = Stack()  # maintain the current axes
        self.axes = []
        self.clf()

        self._cachedRenderer = None

    def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right'):
        """
        A common use case is a number of subplots with shared xaxes
        where the x-axis is date data.  The ticklabels are often
        long,and it helps to rotate them on the bottom subplot and
        turn them off on other subplots.  This function will raise a
        RuntimeError if any of the Axes are not Subplots.

        bottom : the bottom of the subplots for subplots_adjust
        rotation: the rotation of the xtick labels
        ha : the horizontal alignment of the xticklabels


        """

        for ax in self.get_axes():
            if not hasattr(ax, 'is_last_row'):
                raise RuntimeError('Axes must be subplot instances; found %s'%type(ax))
            if ax.is_last_row():
                for label in ax.get_xticklabels():
                    label.set_ha(ha)
                    label.set_rotation(rotation)
            else:
                for label in ax.get_xticklabels():
                    label.set_visible(False)
        self.subplots_adjust(bottom=bottom)

    def get_children(self):
        'get a list of artists contained in the figure'
        children = [self.figurePatch]
        children.extend(self.axes)
        children.extend(self.lines)
        children.extend(self.patches)
        children.extend(self.texts)
        children.extend(self.images)
        children.extend(self.legends)
        return children

    def contains(self, mouseevent):
#.........这里部分代码省略.........
开发者ID:gkliska,项目名称:razvoj,代码行数:101,代码来源:figure.py

示例9: get_window_extent

    def get_window_extent(self, renderer):
        "Return the bounding box of the table in window coords"
        boxes = [cell.get_window_extent(renderer) for cell in self._cells.values()]

        return Bbox.union(boxes)
开发者ID:chensunn,项目名称:PortableJekyll,代码行数:5,代码来源:table.py

示例10: __init__

    def __init__(
        self,
        figsize=None,  # defaults to rc figure.figsize
        dpi=None,  # defaults to rc figure.dpi
        facecolor=None,  # defaults to rc figure.facecolor
        edgecolor=None,  # defaults to rc figure.edgecolor
        linewidth=0.0,  # the default linewidth of the frame
        frameon=True,  # whether or not to draw the figure frame
        subplotpars=None,  # default to rc
    ):
        """
        *figsize*
            w,h tuple in inches

        *dpi*
            Dots per inch

        *facecolor*
            The figure patch facecolor; defaults to rc ``figure.facecolor``

        *edgecolor*
            The figure patch edge color; defaults to rc ``figure.edgecolor``

        *linewidth*
            The figure patch edge linewidth; the default linewidth of the frame

        *frameon*
            If *False*, suppress drawing the figure frame

        *subplotpars*
            A :class:`SubplotParams` instance, defaults to rc
        """
        Artist.__init__(self)

        self.callbacks = cbook.CallbackRegistry()

        if figsize is None:
            figsize = rcParams["figure.figsize"]
        if dpi is None:
            dpi = rcParams["figure.dpi"]
        if facecolor is None:
            facecolor = rcParams["figure.facecolor"]
        if edgecolor is None:
            edgecolor = rcParams["figure.edgecolor"]

        self.dpi_scale_trans = Affine2D()
        self.dpi = dpi
        self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
        self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans)

        self.frameon = frameon

        self.transFigure = BboxTransformTo(self.bbox)

        # the figurePatch name is deprecated
        self.patch = self.figurePatch = Rectangle(
            xy=(0, 0), width=1, height=1, facecolor=facecolor, edgecolor=edgecolor, linewidth=linewidth
        )
        self._set_artist_props(self.patch)
        self.patch.set_aa(False)

        self._hold = rcParams["axes.hold"]
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self._axstack = AxesStack()  # track all figure axes and current axes
        self.clf()
        self._cachedRenderer = None
开发者ID:jjs0sbw,项目名称:CSPLN,代码行数:72,代码来源:figure.py

示例11: get_window_extent

 def get_window_extent(self, renderer):
     'Return the bounding box of the table in window coords'
     boxes = [c.get_window_extent(renderer) for c in self._cells]
     return Bbox.union(boxes)
开发者ID:chrishowes,项目名称:matplotlib,代码行数:4,代码来源:table.py


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