本文整理匯總了Python中matplotlib.transforms.Bbox.unit方法的典型用法代碼示例。如果您正苦於以下問題:Python Bbox.unit方法的具體用法?Python Bbox.unit怎麽用?Python Bbox.unit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.transforms.Bbox
的用法示例。
在下文中一共展示了Bbox.unit方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _set_lim_and_transforms
# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import unit [as 別名]
def _set_lim_and_transforms(self):
"""
"""
PolarAxes._set_lim_and_transforms(self)
self.transProjection = self.DipPolarTransform()
# pylint: attribute-defined-outside-init,invalid-name
self.transData = (
self.transScale +
self.transProjection +
(self.transProjectionAffine + self.transAxes))
# pylint: attribute-defined-outside-init,invalid-name
self._xaxis_transform = (
self.transProjection +
self.PolarAffine(IdentityTransform(), Bbox.unit()) +
self.transAxes) # pylint: attribute-defined-outside-init
self._xaxis_text1_transform = (
self._theta_label1_position +
self._xaxis_transform) # pylint: attribute-defined-outside-init
self._yaxis_transform = (
Affine2D().scale(np.pi * 2.0, 1.0) +
self.transData) # pylint: attribute-defined-outside-init
self._yaxis_text1_transform = (
Affine2D().scale(1.0 / 360.0, 1.0) +
self._yaxis_transform) # pylint: attribute-defined-outside-init
示例2: _get_xy_display
# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import unit [as 別名]
def _get_xy_display(self):
'get the (possibly unit converted) transformed x, y in display coords'
x, y = self.get_position()
return self.get_transform().transform_point((x, y))
示例3: __init__
# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import unit [as 別名]
def __init__(self, artist, ref_coord, unit="points"):
self._artist = artist
self._ref_coord = ref_coord
self.set_unit(unit)
示例4: set_unit
# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import unit [as 別名]
def set_unit(self, unit):
assert unit in ["points", "pixels"]
self._unit = unit
示例5: _get_scale
# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import unit [as 別名]
def _get_scale(self, renderer):
unit = self.get_unit()
if unit == "pixels":
return 1.
else:
return renderer.points_to_pixels(1.)
示例6: get_window_extent
# 需要導入模塊: from matplotlib.transforms import Bbox [as 別名]
# 或者: from matplotlib.transforms.Bbox import unit [as 別名]
def get_window_extent(self, renderer=None, dpi=None):
'''
Return a :class:`~matplotlib.transforms.Bbox` object bounding
the text, in display units.
In addition to being used internally, this is useful for
specifying clickable regions in a png file on a web page.
*renderer* defaults to the _renderer attribute of the text
object. This is not assigned until the first execution of
:meth:`draw`, so you must use this kwarg if you want
to call :meth:`get_window_extent` prior to the first
:meth:`draw`. For getting web page regions, it is
simpler to call the method after saving the figure.
*dpi* defaults to self.figure.dpi; the renderer dpi is
irrelevant. For the web application, if figure.dpi is not
the value used when saving the figure, then the value that
was used must be specified as the *dpi* argument.
'''
#return _unit_box
if not self.get_visible():
return Bbox.unit()
if dpi is not None:
dpi_orig = self.figure.dpi
self.figure.dpi = dpi
if self.get_text().strip() == '':
tx, ty = self._get_xy_display()
return Bbox.from_bounds(tx, ty, 0, 0)
if renderer is not None:
self._renderer = renderer
if self._renderer is None:
raise RuntimeError('Cannot get window extent w/o renderer')
bbox, info, descent = self._get_layout(self._renderer)
x, y = self.get_position()
x, y = self.get_transform().transform_point((x, y))
bbox = bbox.translated(x, y)
if dpi is not None:
self.figure.dpi = dpi_orig
return bbox