本文整理汇总了Python中matplotlib.transforms.Bbox.unit方法的典型用法代码示例。如果您正苦于以下问题:Python Bbox.unit方法的具体用法?Python Bbox.unit怎么用?Python Bbox.unit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.transforms.Bbox
的用法示例。
在下文中一共展示了Bbox.unit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.NorthPolarTransform()
self.axisProjection = self.NorthPolarAxisTransform()
self.transData = (
Affine2D().scale(numpy.pi/180.0, 1.0/90.0) +
self.transScale +
self.transProjection +
(self.transProjectionAffine + self.transAxes))
self._xaxis_pretransform = (
Affine2D().scale(1.0, 1.0) )
self._xaxis_transform = (
self._xaxis_pretransform +
self.axisProjection +
self.PolarAffine(IdentityTransform(), Bbox.unit()) +
self.transAxes)
self._xaxis_text1_transform = (
self._theta_label1_position +
self._xaxis_transform)
self._yaxis_transform = (
Affine2D().scale(numpy.pi*2.0, 1.0) +
self.transScale +
self.axisProjection +
(self.transProjectionAffine + self.transAxes))
self._yaxis_text1_transform = (
self._r_label1_position +
Affine2D().translate(0.0, -0.051) +
self._yaxis_transform)
示例2: _set_lim_and_transforms
# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import unit [as 别名]
def _set_lim_and_transforms(self):
self.transAxes = BboxTransformTo(self.bbox)
self.transScale = TransformWrapper(IdentityTransform())
self.transProjection = self.PolarTransform()
self.transProjectionAffine = self.PolarAffine(self.transScale, self.viewLim)
self.transData = self.transScale + self.transProjection + \
(self.transProjectionAffine + self.transAxes)
self._xaxis_transform = (
self.transProjection +
self.PolarAffine(IdentityTransform(), Bbox.unit()) +
self.transAxes)
self._theta_label1_position = Affine2D().translate(0.0, 1.1)
self._xaxis_text1_transform = (
self._theta_label1_position +
self._xaxis_transform)
self._theta_label2_position = Affine2D().translate(0.0, 1.0 / 1.1)
self._xaxis_text2_transform = (
self._theta_label2_position +
self._xaxis_transform)
self._yaxis_transform = (
Affine2D().scale(npy.pi * 2.0, 1.0) +
self.transData)
self._r_label1_position = Affine2D().translate(22.5, self._rpad)
self._yaxis_text1_transform = (
self._r_label1_position +
Affine2D().scale(1.0 / 360.0, 1.0) +
self._yaxis_transform
)
self._r_label2_position = Affine2D().translate(22.5, self._rpad)
self._yaxis_text2_transform = (
self._r_label2_position +
Affine2D().scale(1.0 / 360.0, 1.0) +
self._yaxis_transform
)
示例3: _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)
try:
theta_position = self._theta_label1_position
except AttributeError:
theta_position = self.get_theta_offset()
self.transProjection = self.GlobeCrossSectionTransform()
self.transData = (
self.transScale +
self.transProjection +
(self.transProjectionAffine + self.transAxes))
self._xaxis_transform = (
self.transProjection +
self.PolarAffine(IdentityTransform(), Bbox.unit()) +
self.transAxes)
self._xaxis_text1_transform = (
theta_position +
self._xaxis_transform)
self._yaxis_transform = (
Affine2D().scale(num.pi * 2.0, 1.0) +
self.transData)
try:
rlp = getattr(self, '_r_label1_position')
except AttributeError:
rlp = getattr(self, '_r_label_position')
self._yaxis_text1_transform = (
rlp +
Affine2D().scale(1.0 / 360.0, 1.0) +
self._yaxis_transform)
示例4: _set_lim_and_transforms
# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import unit [as 别名]
def _set_lim_and_transforms(self):
"""
Overrides the method with the same name in the PolarAxes-class.
This method replaces the same method in the PolarAxes-class. It ensures
that the limits and label placement fit the north-polar projection.
"""
PolarAxes._set_lim_and_transforms(self)
self.transProjection = self.NorthPolarTransform()
# 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
示例5: draw_plot
# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import unit [as 别名]
def draw_plot(self):
if self._doRePlot:
self._resizeCreateContent()
if self.background is None:
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
self.foo += 1
#self.y = numpy.cos(numpy.arange(0.0,1.0,0.1)+self.foo*0.1)
# Optimization on the blitting: we compute the box where the changes happen
changes_box = None
for i in range(len(self.lines)):
data=self.channels[i].getNext()
if len(data[1])>0:
if self.autolim:
print self.autolim[0], data[1], self.autolim[1]
self.autolim = [ min(self.autolim[0], min(data[1])), \
max(self.autolim[1], max(data[1])) ]
else:
self.autolim = [ min(data[1]), min(data[1]) ]
if changes_box is None:
changes_box = Bbox.unit()
print '>>>>>>>>'
print data[0], data[1]
changes_box.update_from_data(numpy.array(data[0]), \
numpy.array(data[1]), ignore=changes_box.is_unit())
if not self._doRePlot and len(data[0]) > 0 :
end = data[0][-1]
if end > self.begin+self.span:
self.begin += self.span
self._doRePlot = True
print 'do replot'
self.lines[i].set_data(data[0], data[1])
else:
self.lines[i].set_data([], [])
if not changes_box:
return
#self.canvas.restore_region(self.background)
for line in self.lines:
self.ax.draw_artist(line)
#print line.get_transform()
tr = line.get_transform()
changes_box_inframe = changes_box.transformed(tr)
box_padding = 5
(x,y,l,w) = changes_box_inframe.bounds
changes_box_inframe = Bbox.from_bounds(x-box_padding, \
y-box_padding, l+2*box_padding, w+2*box_padding)
#print
t0 = time.time()
self.canvas.blit(None)
#self.canvas.blit(changes_box_inframe)
self.blit_time += time.time() - t0
示例6: _set_lim_and_transforms
# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import unit [as 别名]
def _set_lim_and_transforms(self):
self.transAxes = 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
self.transScale = TransformWrapper(IdentityTransform())
# A (possibly non-linear) projection on the (already scaled) data
self.transProjection = self.PolarTransform()
# An affine transformation on the data, generally to limit the
# range of the axes
self.transProjectionAffine = self.PolarAffine(self.transScale, self.viewLim)
# The complete data transformation stack -- from data all the
# way to display coordinates
self.transData = self.transScale + IdentityTransform() + \
(self.transProjectionAffine + self.transAxes)
# old version of the previous line
self.transGrid = self.transScale + self.transProjection + \
(self.transProjectionAffine + self.transAxes)
# This is the transform for theta-axis ticks. It is
# equivalent to transData, except it always puts r == 1.0 at
# the edge of the axis circle.
self._xaxis_transform = (
self.transProjection +
self.PolarAffine(IdentityTransform(), Bbox.unit()) +
self.transAxes)
# The theta labels are moved from radius == 0.0 to radius == 1.1
self._theta_label1_position = Affine2D().translate(0.0, 1.1)
self._xaxis_text1_transform = (
self._theta_label1_position +
self._xaxis_transform)
self._theta_label2_position = Affine2D().translate(0.0, 1.0 / 1.1)
self._xaxis_text2_transform = (
self._theta_label2_position +
self._xaxis_transform)
# This is the transform for r-axis ticks. It scales the theta
# axis so the gridlines from 0.0 to 1.0, now go from 0.0 to
# 2pi.
self._yaxis_transform = (
Affine2D().scale(npy.pi * 2.0, 1.0) +
self.transGrid)
# The r-axis labels are put at an angle and padded in the r-direction
self._r_label1_position = Affine2D().translate(22.5, self._rpad)
self._yaxis_text1_transform = (
self._r_label1_position +
Affine2D().scale(1.0 / 360.0, 1.0) +
self._yaxis_transform
)
self._r_label2_position = Affine2D().translate(22.5, self._rpad)
self._yaxis_text2_transform = (
self._r_label2_position +
Affine2D().scale(1.0 / 360.0, 1.0) +
self._yaxis_transform
)
示例7: _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.GlobeCrossSectionTransform(GlobeCrossSectionAxes.RESOLUTION)
self.transData = self.transScale + self.transProjection + (self.transProjectionAffine + self.transAxes)
self._xaxis_transform = (
self.transProjection + self.PolarAffine(IdentityTransform(), Bbox.unit()) + self.transAxes
)
self._xaxis_text1_transform = self._theta_label1_position + self._xaxis_transform
self._yaxis_transform = Affine2D().scale(num.pi * 2.0, 1.0) + self.transData
self._yaxis_text1_transform = (
self._r_label1_position + Affine2D().scale(1.0 / 360.0, 1.0) + self._yaxis_transform
)
示例8: _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.NorthPolarTransform()
self.transData = (
self.transScale +
self.transProjection +
(self.transProjectionAffine + self.transAxes))
self._xaxis_transform = (
self.transProjection +
self.PolarAffine(IdentityTransform(), Bbox.unit()) +
self.transAxes)
self._xaxis_text1_transform = (
self._theta_label1_position +
self._xaxis_transform)
self._yaxis_transform = (
Affine2D().scale(np.pi * 2.0, 1.0) +
self.transData)
示例9: draw_plot
# 需要导入模块: from matplotlib.transforms import Bbox [as 别名]
# 或者: from matplotlib.transforms.Bbox import unit [as 别名]
def draw_plot(self):
if self._doRePlot:
self._resizeCreateContent()
if self.background is None:
self.background = self.canvas.copy_from_bbox(self.ax.bbox)
changes_box = None
#try:
for i in range(len(self.lines)):
data=self.channels[i].getNext()
if len(data[0]) > 0:
if len(data[0]) != len(data[1]):
print 'incoherent data', len(data[0]), len(data[1])
return
# Add new points
#print type(self.cached_datax[i]), type(data[0])
if isinstance(data[0], numpy.ndarray):
self.cached_datax[i] += list(data[0])
self.cached_datay[i] += data[1].tolist()
else:
self.cached_datax[i] += data[0]
self.cached_datay[i] += data[1]
if len(data[1])>0:
if self.autolim:
self.autolim = [ min(self.autolim[0], min(data[1])), \
max(self.autolim[1], max(data[1])) ]
else:
self.autolim = [ min(data[1]), min(data[1]) ]
if changes_box is None:
changes_box = Bbox.unit()
changes_box.update_from_data(numpy.array(data[0]), \
numpy.array(data[1]), ignore=changes_box.is_unit())
if not self._doRePlot and len(data[0]) > 0 :
end = data[0][-1]
if end > self.begin+self.span:
self.begin = end
self._doRePlot = True
#print 'C'
#self.cached_datax[i] += (data[0])
#self.cached_datay[i] += (data[1])
#print self.cached_datay[i], self.cached_datax[i]
self.lines[i].set_data(self.cached_datax[i], \
self.cached_datay[i])
#self.lines[i].set_data(data[0], data[1])
else:
self.lines[i].set_data([], [])
if not changes_box:
return
for line in self.lines:
self.ax.draw_artist(line)
tr = line.get_transform()
changes_box_inframe = changes_box.transformed(tr)
box_xpadding = 20
box_ypadding = 100
(x,y,l,w) = changes_box_inframe.bounds
changes_box_inframe = Bbox.from_bounds(x-box_xpadding, \
y-box_ypadding, l+2*box_xpadding, w+2*box_ypadding)
#self.canvas.blit(None)
self.canvas.blit(changes_box_inframe)