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


Python transforms.BboxTransformTo方法代碼示例

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


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

示例1: _update_patch_transform

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def _update_patch_transform(self):
        """NOTE: This cannot be called until after this has been added
                 to an Axes, otherwise unit conversion will fail. This
                 maxes it very important to call the accessor method and
                 not directly access the transformation member variable.
        """
        x = self.convert_xunits(self._x)
        y = self.convert_yunits(self._y)
        width = self.convert_xunits(self._width)
        height = self.convert_yunits(self._height)
        bbox = transforms.Bbox.from_bounds(x, y, width, height)
        rot_trans = transforms.Affine2D()
        rot_trans.rotate_deg_around(x, y, self._angle)
        self._rect_transform = transforms.BboxTransformTo(bbox)
        self._rect_transform += rot_trans 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:17,代碼來源:patches.py

示例2: set_bbox_to_anchor

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

        *bbox* can be a BboxBase instance, a tuple of [left, bottom,
        width, height] in the given transform (normalized axes
        coordinate if None), or a tuple of [left, bottom] where the
        width and height will be assumed to be zero.
        """
        if bbox is None:
            self._bbox_to_anchor = None
            return
        elif 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)

        if transform is None:
            transform = BboxTransformTo(self.parent.bbox)

        self._bbox_to_anchor = TransformedBbox(self._bbox_to_anchor,
                                               transform) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:32,代碼來源:legend.py

示例3: __call__

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def __call__(self, ax, renderer):
       bbox_parent = self.parent.get_position(original=False)
       trans = mtrans.BboxTransformTo(bbox_parent)
       bbox_inset = mtrans.Bbox.from_bounds(*self.lbwh)
       bb = mtrans.TransformedBbox(bbox_inset, trans)
       return bb 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:8,代碼來源:inset_locator.py

示例4: set_bbox_to_anchor

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

        *bbox* can be

        - A `.BboxBase` instance
        - A tuple of ``(left, bottom, width, height)`` in the given transform
          (normalized axes coordinate if None)
        - A tuple of ``(left, bottom)`` where the width and height will be
          assumed to be zero.
        """
        if bbox is None:
            self._bbox_to_anchor = None
            return
        elif 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)

        if transform is None:
            transform = BboxTransformTo(self.parent.bbox)

        self._bbox_to_anchor = TransformedBbox(self._bbox_to_anchor,
                                               transform)
        self.stale = True 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:36,代碼來源:legend.py

示例5: _set_lim_and_transforms

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def _set_lim_and_transforms(self):
        """
        Set the *_xaxis_transform*, *_yaxis_transform*, *transScale*,
        *transData*, *transLimits* and *transAxes* transformations.

        .. note::

            This method is primarily used by rectilinear projections of the
            `~matplotlib.axes.Axes` class, and is meant to be overridden by
            new kinds of projection axes that need different transformations
            and limits. (See `~matplotlib.projections.polar.PolarAxes` for an
            example.)
        """
        self.transAxes = mtransforms.BboxTransformTo(self.bbox)

        # Transforms the x and y axis separately by a scale factor.
        # It is assumed that this part will have non-linear components
        # (e.g., for a log scale).
        self.transScale = mtransforms.TransformWrapper(
            mtransforms.IdentityTransform())

        # An affine transformation on the data, generally to limit the
        # range of the axes
        self.transLimits = mtransforms.BboxTransformFrom(
            mtransforms.TransformedBbox(self.viewLim, self.transScale))

        # The parentheses are important for efficiency here -- they
        # group the last two (which are usually affines) separately
        # from the first (which, with log-scaling can be non-affine).
        self.transData = self.transScale + (self.transLimits + self.transAxes)

        self._xaxis_transform = mtransforms.blended_transform_factory(
            self.transData, self.transAxes)
        self._yaxis_transform = mtransforms.blended_transform_factory(
            self.transAxes, self.transData) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:37,代碼來源:_base.py

示例6: _set_lim_and_transforms

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def _set_lim_and_transforms(self):
        """
        set the *dataLim* and *viewLim*
        :class:`~matplotlib.transforms.Bbox` attributes and the
        *transScale*, *transData*, *transLimits* and *transAxes*
        transformations.

        .. note::

            This method is primarily used by rectilinear projections
            of the :class:`~matplotlib.axes.Axes` class, and is meant
            to be overridden by new kinds of projection axes that need
            different transformations and limits. (See
            :class:`~matplotlib.projections.polar.PolarAxes` for an
            example.

        """
        self.transAxes = mtransforms.BboxTransformTo(self.bbox)

        # Transforms the x and y axis separately by a scale factor.
        # It is assumed that this part will have non-linear components
        # (e.g., for a log scale).
        self.transScale = mtransforms.TransformWrapper(
            mtransforms.IdentityTransform())

        # An affine transformation on the data, generally to limit the
        # range of the axes
        self.transLimits = mtransforms.BboxTransformFrom(
            mtransforms.TransformedBbox(self.viewLim, self.transScale))

        # The parentheses are important for efficiency here -- they
        # group the last two (which are usually affines) separately
        # from the first (which, with log-scaling can be non-affine).
        self.transData = self.transScale + (self.transLimits + self.transAxes)

        self._xaxis_transform = mtransforms.blended_transform_factory(
            self.transData, self.transAxes)
        self._yaxis_transform = mtransforms.blended_transform_factory(
            self.transAxes, self.transData) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:41,代碼來源:_base.py

示例7: _set_lim_and_transforms

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def _set_lim_and_transforms(self):
        """
        set the *_xaxis_transform*, *_yaxis_transform*,
        *transScale*, *transData*, *transLimits* and *transAxes*
        transformations.

        .. note::

            This method is primarily used by rectilinear projections
            of the :class:`~matplotlib.axes.Axes` class, and is meant
            to be overridden by new kinds of projection axes that need
            different transformations and limits. (See
            :class:`~matplotlib.projections.polar.PolarAxes` for an
            example.

        """
        self.transAxes = mtransforms.BboxTransformTo(self.bbox)

        # Transforms the x and y axis separately by a scale factor.
        # It is assumed that this part will have non-linear components
        # (e.g., for a log scale).
        self.transScale = mtransforms.TransformWrapper(
            mtransforms.IdentityTransform())

        # An affine transformation on the data, generally to limit the
        # range of the axes
        self.transLimits = mtransforms.BboxTransformFrom(
            mtransforms.TransformedBbox(self.viewLim, self.transScale))

        # The parentheses are important for efficiency here -- they
        # group the last two (which are usually affines) separately
        # from the first (which, with log-scaling can be non-affine).
        self.transData = self.transScale + (self.transLimits + self.transAxes)

        self._xaxis_transform = mtransforms.blended_transform_factory(
            self.transData, self.transAxes)
        self._yaxis_transform = mtransforms.blended_transform_factory(
            self.transAxes, self.transData) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:40,代碼來源:_base.py

示例8: __call__

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def __call__(self, ax, renderer):
        bbox_parent = self.parent.get_position(original=False)
        trans = BboxTransformTo(bbox_parent)
        bbox_inset = Bbox.from_bounds(*self.lbwh)
        bb = TransformedBbox(bbox_inset, trans)
        return bb 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:8,代碼來源:inset_locator.py

示例9: convert_point

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def convert_point(self,point_px, stop=False):
      '''
      given a touch point in the view space, compute the corresponding point in data coords. assumes linear scaling!
      TODO: support log scaling 
      
      there are basically two bbox transforms:  1) from figure coords to view coords, accounting for sign change in y. this then lets us compute axes box in view coords, and generate 2) transform from view to data coords.

      '''
      transFig=BboxTransformTo(Bbox([(0,self.height),(self.width,0)]))
      bbox_axes=Bbox(transFig.transform(plt.gca().get_position()))
      bbox_data=Bbox([(self.xlim[0],self.ylim[0]),(self.xlim[1],self.ylim[1])])
      transMPL=BboxTransform(bbox_axes,bbox_data)
      self.trans=transMPL
      ax_pt=transMPL.transform_point(point_px)      
      return ax_pt 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:17,代碼來源:SPLView.py

示例10: compute_lims

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def compute_lims(self):
      '''compute new axes limits based on pan/zoom.
         basically, get limits in terms of bbox of size 1.  
         transform to bbox of size orig lims.       
      '''
      xlnorm=      self.hslider.barvalue+np.array([-.5,.5])*self.hslider.barwidth
      ylnorm=      self.vslider.barvalue+np.array([-.5,.5])*self.vslider.barwidth
      viewBbox=Bbox(zip(xlnorm,ylnorm))
      limBB=Bbox(zip(self.xlim,self.ylim))
      newlims=Bbox(BboxTransformTo(limBB).transform(viewBbox))
      return [(newlims.x0,newlims.x1),(newlims.y0,newlims.y1)] 
開發者ID:khilnani,項目名稱:pythonista-scripts,代碼行數:13,代碼來源:SPLView11.py

示例11: _set_lim_and_transforms

# 需要導入模塊: from matplotlib import transforms [as 別名]
# 或者: from matplotlib.transforms import BboxTransformTo [as 別名]
def _set_lim_and_transforms(self):
        # A (possibly non-linear) projection on the (already scaled) data
        self.transProjection = self._get_core_transform(self.RESOLUTION)

        self.transAffine = self._get_affine_transform()

        self.transAxes = BboxTransformTo(self.bbox)

        # The complete data transformation stack -- from data all the
        # way to display coordinates
        self.transData = \
            self.transProjection + \
            self.transAffine + \
            self.transAxes

        # This is the transform for longitude ticks.
        self._xaxis_pretransform = \
            Affine2D() \
            .scale(1, self._longitude_cap * 2) \
            .translate(0, -self._longitude_cap)
        self._xaxis_transform = \
            self._xaxis_pretransform + \
            self.transData
        self._xaxis_text1_transform = \
            Affine2D().scale(1, 0) + \
            self.transData + \
            Affine2D().translate(0, 4)
        self._xaxis_text2_transform = \
            Affine2D().scale(1, 0) + \
            self.transData + \
            Affine2D().translate(0, -4)

        # This is the transform for latitude ticks.
        yaxis_stretch = Affine2D().scale(np.pi * 2, 1).translate(-np.pi, 0)
        yaxis_space = Affine2D().scale(1, 1.1)
        self._yaxis_transform = \
            yaxis_stretch + \
            self.transData
        yaxis_text_base = \
            yaxis_stretch + \
            self.transProjection + \
            (yaxis_space + \
             self.transAffine + \
             self.transAxes)
        self._yaxis_text1_transform = \
            yaxis_text_base + \
            Affine2D().translate(-8, 0)
        self._yaxis_text2_transform = \
            yaxis_text_base + \
            Affine2D().translate(8, 0) 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:52,代碼來源:geo.py


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