本文整理汇总了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
示例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)
示例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
示例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
示例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)
示例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)
示例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)
示例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
示例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
示例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)]
示例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)