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


Python transforms.Bbox方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def __init__(self, meshWidth, meshHeight, coordinates,
                 antialiased=True, shading='flat', **kwargs):
        Collection.__init__(self, **kwargs)
        self._meshWidth = meshWidth
        self._meshHeight = meshHeight
        self._coordinates = coordinates
        self._antialiased = antialiased
        self._shading = shading

        self._bbox = transforms.Bbox.unit()
        self._bbox.update_from_data_xy(coordinates.reshape(
            ((meshWidth + 1) * (meshHeight + 1), 2)))

        # By converting to floats now, we can avoid that on every draw.
        self._coordinates = self._coordinates.reshape(
            (meshHeight + 1, meshWidth + 1, 2))
        self._coordinates = np.array(self._coordinates, np.float_) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:19,代碼來源:collections.py

示例2: set_figure

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def set_figure(self, fig):
        """
        Set the `.Figure` for this `.Axes`.

        Parameters
        ----------
        fig : `.Figure`
        """
        martist.Artist.set_figure(self, fig)

        self.bbox = mtransforms.TransformedBbox(self._position,
                                                fig.transFigure)
        # these will be updated later as data is added
        self.dataLim = mtransforms.Bbox.null()
        self.viewLim = mtransforms.Bbox.unit()
        self.transScale = mtransforms.TransformWrapper(
            mtransforms.IdentityTransform())

        self._set_lim_and_transforms() 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:21,代碼來源:_base.py

示例3: get_position

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def get_position(self, original=False):
        """
        Get a copy of the axes rectangle as a `.Bbox`.

        Parameters
        ----------
        original : bool
            If ``True``, return the original position. Otherwise return the
            active position. For an explanation of the positions see
            `.set_position`.

        Returns
        -------
        pos : `.Bbox`

        """
        if original:
            return self._originalPosition.frozen()
        else:
            locator = self.get_axes_locator()
            if not locator:
                self.apply_aspect()
            return self._position.frozen() 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:25,代碼來源:_base.py

示例4: set_figure

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def set_figure(self, fig):
        """
        Set the class:`~matplotlib.axes.Axes` figure

        accepts a class:`~matplotlib.figure.Figure` instance
        """
        martist.Artist.set_figure(self, fig)

        self.bbox = mtransforms.TransformedBbox(self._position,
                                                fig.transFigure)
        # these will be updated later as data is added
        self.dataLim = mtransforms.Bbox.null()
        self.viewLim = mtransforms.Bbox.unit()
        self.transScale = mtransforms.TransformWrapper(
            mtransforms.IdentityTransform())

        self._set_lim_and_transforms() 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:19,代碼來源:_base.py

示例5: relim

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def relim(self, visible_only=False):
        """
        Recompute the data limits based on current artists. If you want to
        exclude invisible artists from the calculation, set
        ``visible_only=True``

        At present, :class:`~matplotlib.collections.Collection`
        instances are not supported.
        """
        # Collections are deliberately not supported (yet); see
        # the TODO note in artists.py.
        self.dataLim.ignore(True)
        self.dataLim.set_points(mtransforms.Bbox.null().get_points())
        self.ignore_existing_data_limits = True

        for line in self.lines:
            if not visible_only or line.get_visible():
                self._update_line_limits(line)

        for p in self.patches:
            if not visible_only or p.get_visible():
                self._update_patch_limits(p) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:24,代碼來源:_base.py

示例6: set_position

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def set_position(self, pos, which='both'):
        """
        Set the axes position.

        Axes have two position attributes. The 'original' position is the
        position allocated for the Axes. The 'active' position is the
        position the Axes is actually drawn at. These positions are usually
        the same unless a fixed aspect is set to the Axes. See `.set_aspect`
        for details.

        Parameters
        ----------
        pos : [left, bottom, width, height] or `~matplotlib.transforms.Bbox`
            The new position of the in `.Figure` coordinates.

        which : {'both', 'active', 'original'}, optional
            Determines which position variables to change.

        """
        self._set_position(pos, which='both')
        # because this is being called externally to the library we
        # zero the constrained layout parts.
        self._layoutbox = None
        self._poslayoutbox = None 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:26,代碼來源:_base.py

示例7: set_position

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def set_position(self, pos, which='both'):
        """
        Set the axes position.

        Axes have two position attributes. The 'original' position is the
        position allocated for the Axes. The 'active' position is the
        position the Axes is actually drawn at. These positions are usually
        the same unless a fixed aspect is set to the Axes. See `.set_aspect`
        for details.

        Parameters
        ----------
        pos : [left, bottom, width, height] or `~matplotlib.transforms.Bbox`
            The new position of the in `.Figure` coordinates.

        which : {'both', 'active', 'original'}, optional
            Determines which position variables to change.

        """
        self._set_position(pos, which=which)
        # because this is being called externally to the library we
        # zero the constrained layout parts.
        self._layoutbox = None
        self._poslayoutbox = None 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:26,代碼來源:_base.py

示例8: test_bbox_intersection

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def test_bbox_intersection():
    bbox_from_ext = mtransforms.Bbox.from_extents
    inter = mtransforms.Bbox.intersection

    r1 = bbox_from_ext(0, 0, 1, 1)
    r2 = bbox_from_ext(0.5, 0.5, 1.5, 1.5)
    r3 = bbox_from_ext(0.5, 0, 0.75, 0.75)
    r4 = bbox_from_ext(0.5, 1.5, 1, 2.5)
    r5 = bbox_from_ext(1, 1, 2, 2)

    # self intersection -> no change
    assert_bbox_eq(inter(r1, r1), r1)
    # simple intersection
    assert_bbox_eq(inter(r1, r2), bbox_from_ext(0.5, 0.5, 1, 1))
    # r3 contains r2
    assert_bbox_eq(inter(r1, r3), r3)
    # no intersection
    assert inter(r1, r4) is None
    # single point
    assert_bbox_eq(inter(r1, r5), bbox_from_ext(1, 1, 1, 1)) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:22,代碼來源:test_transforms.py

示例9: test_bbox_image_inverted

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def test_bbox_image_inverted():
    # This is just used to produce an image to feed to BboxImage
    image = np.arange(100).reshape((10, 10))

    fig, ax = plt.subplots()
    bbox_im = BboxImage(
        TransformedBbox(Bbox([[100, 100], [0, 0]]), ax.transData))
    bbox_im.set_data(image)
    bbox_im.set_clip_on(False)
    ax.set_xlim(0, 100)
    ax.set_ylim(0, 100)
    ax.add_artist(bbox_im)

    image = np.identity(10)

    bbox_im = BboxImage(TransformedBbox(Bbox([[0.1, 0.2], [0.3, 0.25]]),
                                        ax.figure.transFigure))
    bbox_im.set_data(image)
    bbox_im.set_clip_on(False)
    ax.add_artist(bbox_im) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:22,代碼來源:test_image.py

示例10: imagesAsTickMarks

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def imagesAsTickMarks(ax, images):
    TICKYPOS = -.6
    lowerCorner = ax.transData.transform((.8,TICKYPOS-.2))
    upperCorner = ax.transData.transform((1.2,TICKYPOS+.2))
    print(lowerCorner)
    print(upperCorner)
    bbox_image = BboxImage(Bbox([lowerCorner[0],
                                 lowerCorner[1],
                                 upperCorner[0],
                                 upperCorner[1],
                                 ]),
                           norm = None,
                           origin=None,
                           clip_on=False,
                           )

    image = imread(images[0])
    print('img loaded')
    bbox_image.set_data(image)
    ax.add_artist(bbox_image) 
開發者ID:Charestlab,項目名稱:pyrsa,代碼行數:22,代碼來源:imagesAsTickMarks.py

示例11: get_datalim

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def get_datalim(self, transData):
        transform = self.get_transform()
        transOffset = self.get_offset_transform()
        offsets = self._offsets
        paths = self.get_paths()

        if not transform.is_affine:
            paths = [transform.transform_path_non_affine(p) for p in paths]
            transform = transform.get_affine()
        if not transOffset.is_affine:
            offsets = transOffset.transform_non_affine(offsets)
            transOffset = transOffset.get_affine()

        offsets = np.asanyarray(offsets, np.float_)
        if np.ma.isMaskedArray(offsets):
            offsets = offsets.filled(np.nan)
            # get_path_collection_extents handles nan but not masked arrays
        offsets.shape = (-1, 2)                     # Make it Nx2

        if paths:
            result = mpath.get_path_collection_extents(
                transform.frozen(), paths, self.get_transforms(),
                offsets, transOffset.frozen())
            result = result.inverse_transformed(transData)
        else:
            result = transforms.Bbox([[0, 0], [0, 0]])
        return result 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:29,代碼來源:collections.py

示例12: on_draw_event

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def on_draw_event(self, widget, ctx):
        """ GtkDrawable draw event, like expose_event in GTK 2.X
        """
        allocation = self.get_allocation()
        w, h = allocation.width, allocation.height

        if not len(self._bbox_queue):
            if self._need_redraw:
                self._render_figure(w, h)
                bbox_queue = [transforms.Bbox([[0, 0], [w, h]])]
            else:
                return
        else:
            bbox_queue = self._bbox_queue

        for bbox in bbox_queue:
            area = self.copy_from_bbox(bbox)
            buf = np.fromstring(area.to_string_argb(), dtype='uint8')

            x = int(bbox.x0)
            y = h - int(bbox.y1)
            width = int(bbox.x1) - int(bbox.x0)
            height = int(bbox.y1) - int(bbox.y0)

            image = cairo.ImageSurface.create_for_data(
                buf, cairo.FORMAT_ARGB32, width, height)
            ctx.set_source_surface(image, x, y)
            ctx.paint()

        if len(self._bbox_queue):
            self._bbox_queue = []

        return False 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:35,代碼來源:backend_gtk3agg.py

示例13: unit_bbox

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def unit_bbox():
    box = Bbox(np.array([[0, 0], [1, 1]]))
    return box 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:5,代碼來源:axes3d.py

示例14: __init__

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def __init__(self, center, viewLim, originLim, **kwargs):
        mtransforms.Bbox.__init__(self,
                                  np.array([[0.0, 0.0], [1.0, 1.0]], np.float),
                                  **kwargs)
        self._center = center
        self._viewLim = viewLim
        self._originLim = originLim
        self.set_children(viewLim, originLim) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:10,代碼來源:polar.py

示例15: on_draw_event

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import Bbox [as 別名]
def on_draw_event(self, widget, ctx):
        """GtkDrawable draw event, like expose_event in GTK 2.X.
        """
        allocation = self.get_allocation()
        w, h = allocation.width, allocation.height

        if not len(self._bbox_queue):
            Gtk.render_background(
                self.get_style_context(), ctx,
                allocation.x, allocation.y,
                allocation.width, allocation.height)
            bbox_queue = [transforms.Bbox([[0, 0], [w, h]])]
        else:
            bbox_queue = self._bbox_queue

        ctx = backend_cairo._to_context(ctx)

        for bbox in bbox_queue:
            x = int(bbox.x0)
            y = h - int(bbox.y1)
            width = int(bbox.x1) - int(bbox.x0)
            height = int(bbox.y1) - int(bbox.y0)

            buf = cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
                np.asarray(self.copy_from_bbox(bbox)))
            image = cairo.ImageSurface.create_for_data(
                buf.ravel().data, cairo.FORMAT_ARGB32, width, height)
            ctx.set_source_surface(image, x, y)
            ctx.paint()

        if len(self._bbox_queue):
            self._bbox_queue = []

        return False 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:36,代碼來源:backend_gtk3agg.py


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