本文整理汇总了Python中matplotlib.transforms.nonsingular方法的典型用法代码示例。如果您正苦于以下问题:Python transforms.nonsingular方法的具体用法?Python transforms.nonsingular怎么用?Python transforms.nonsingular使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.transforms
的用法示例。
在下文中一共展示了transforms.nonsingular方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: autoscale
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def autoscale(self):
"""
Sets the view limits to the nearest multiples of base that contain the
data.
"""
# requires matplotlib >= 0.98.0
(vmin, vmax) = self.axis.get_data_interval()
locs = self._get_default_locs(vmin, vmax)
(vmin, vmax) = locs[[0, -1]]
if vmin == vmax:
vmin -= 1
vmax += 1
return nonsingular(vmin, vmax)
# -------------------------------------------------------------------------
# --- Formatter ---
# -------------------------------------------------------------------------
示例2: pan
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def pan(self, numsteps):
"""Pan numticks (can be positive or negative)"""
ticks = self()
numticks = len(ticks)
vmin, vmax = self.axis.get_view_interval()
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
if numticks > 2:
step = numsteps * abs(ticks[0] - ticks[1])
else:
d = abs(vmax - vmin)
step = numsteps * d / 6.
vmin += step
vmax += step
self.axis.set_view_interval(vmin, vmax, ignore=True)
示例3: tick_values
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def tick_values(self, vmin, vmax):
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
if vmax < vmin:
vmin, vmax = vmax, vmin
if (vmin, vmax) in self.presets:
return self.presets[(vmin, vmax)]
if self.numticks is None:
self._set_numticks()
if self.numticks == 0:
return []
ticklocs = np.linspace(vmin, vmax, self.numticks)
return self.raise_if_exceeds(ticklocs)
示例4: scale_range
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def scale_range(vmin, vmax, n=1, threshold=100):
dv = abs(vmax - vmin)
if dv == 0: # maxabsv == 0 is a special case of this.
return 1.0, 0.0
# Note: this should never occur because
# vmin, vmax should have been checked by nonsingular(),
# and spread apart if necessary.
meanv = 0.5 * (vmax + vmin)
if abs(meanv) / dv < threshold:
offset = 0
elif meanv > 0:
ex = divmod(math.log10(meanv), 1)[0]
offset = 10 ** ex
else:
ex = divmod(math.log10(-meanv), 1)[0]
offset = -10 ** ex
ex = divmod(math.log10(dv / n), 1)[0]
scale = 10 ** ex
return scale, offset
示例5: autoscale
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def autoscale(self):
"""
Sets the view limits to the nearest multiples of base that contain the
data.
"""
# requires matplotlib >= 0.98.0
(vmin, vmax) = self.axis.get_data_interval()
locs = self._get_default_locs(vmin, vmax)
(vmin, vmax) = locs[[0, -1]]
if vmin == vmax:
vmin -= 1
vmax += 1
return nonsingular(vmin, vmax)
#####-------------------------------------------------------------------------
#---- --- Formatter ---
#####-------------------------------------------------------------------------
示例6: __call__
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def __call__(self, x, pos=None):
"""
Return the format for tick val *x*.
"""
if x == 0.0: # Symlog
return '0'
x = abs(x)
b = self._base
# only label the decades
fx = math.log(x) / math.log(b)
is_x_decade = is_close_to_int(fx)
exponent = np.round(fx) if is_x_decade else np.floor(fx)
coeff = np.round(x / b ** exponent)
if self.labelOnlyBase and not is_x_decade:
return ''
if self._sublabels is not None and coeff not in self._sublabels:
return ''
vmin, vmax = self.axis.get_view_interval()
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
s = self._num_to_string(x, vmin, vmax)
return self.fix_minus(s)
示例7: view_limits
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def view_limits(self, vmin, vmax):
'Try to choose the view limits intelligently'
if vmax < vmin:
vmin, vmax = vmax, vmin
if vmin == vmax:
vmin -= 1
vmax += 1
if rcParams['axes.autolimit_mode'] == 'round_numbers':
exponent, remainder = divmod(
math.log10(vmax - vmin), math.log10(max(self.numticks - 1, 1)))
exponent -= (remainder < .5)
scale = max(self.numticks - 1, 1) ** (-exponent)
vmin = math.floor(scale * vmin) / scale
vmax = math.ceil(scale * vmax) / scale
return mtransforms.nonsingular(vmin, vmax)
示例8: tick_values
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def tick_values(self, vmin, vmax):
if self._symmetric:
vmax = max(abs(vmin), abs(vmax))
vmin = -vmax
vmin, vmax = mtransforms.nonsingular(
vmin, vmax, expander=1e-13, tiny=1e-14)
locs = self._raw_ticks(vmin, vmax)
prune = self._prune
if prune == 'lower':
locs = locs[1:]
elif prune == 'upper':
locs = locs[:-1]
elif prune == 'both':
locs = locs[1:-1]
return self.raise_if_exceeds(locs)
示例9: nonsingular
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def nonsingular(self, vmin, vmax):
if not np.isfinite(vmin) or not np.isfinite(vmax):
return 1, 10 # initial range, no data plotted yet
if vmin > vmax:
vmin, vmax = vmax, vmin
if vmax <= 0:
cbook._warn_external(
"Data has no positive values, and therefore cannot be "
"log-scaled.")
return 1, 10
minpos = self.axis.get_minpos()
if not np.isfinite(minpos):
minpos = 1e-300 # This should never take effect.
if vmin <= 0:
vmin = minpos
if vmin == vmax:
vmin = _decade_less(vmin, self._base)
vmax = _decade_greater(vmax, self._base)
return vmin, vmax
示例10: __call__
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def __call__(self, x, pos=None):
"""Return the format for tick val *x* at position *pos*"""
vmin, vmax = self.axis.get_view_interval()
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
d = abs(vmax - vmin)
b = self._base
if x == 0:
return '0'
sign = np.sign(x)
# only label the decades
fx = math.log(abs(x)) / math.log(b)
isDecade = is_close_to_int(fx)
if not isDecade and self.labelOnlyBase:
s = ''
elif abs(fx) > 10000:
s = '%1.0g' % fx
elif abs(fx) < 1:
s = '%1.0g' % fx
else:
s = self.pprint_val(fx, d)
if sign == -1:
s = '-%s' % s
return self.fix_minus(s)
示例11: view_limits
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def view_limits(self, dmin, dmax):
"""
Set the view limits to the nearest multiples of base that
contain the data.
"""
if rcParams['axes.autolimit_mode'] == 'round_numbers':
vmin = self._edge.le(dmin) * self._edge.step
vmax = self._base.ge(dmax) * self._edge.step
if vmin == vmax:
vmin -= 1
vmax += 1
else:
vmin = dmin
vmax = dmax
return mtransforms.nonsingular(vmin, vmax)
示例12: __call__
# 需要导入模块: from matplotlib import transforms [as 别名]
# 或者: from matplotlib.transforms import nonsingular [as 别名]
def __call__(self, x, pos=None):
"""Return the format for tick val *x* at position *pos*"""
vmin, vmax = self.axis.get_view_interval()
vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05)
d = abs(vmax - vmin)
b = self._base
if x == 0:
return '0'
sign = np.sign(x)
# only label the decades
fx = math.log(abs(x)) / math.log(b)
isDecade = is_close_to_int(fx)
if not isDecade and self.labelOnlyBase:
s = ''
#if 0: pass
elif fx > 10000:
s = '%1.0e' % fx
#elif x<1: s = '$10^{%d}$'%fx
#elif x<1: s = '10^%d'%fx
elif fx < 1:
s = '%1.0e' % fx
else:
s = self.pprint_val(fx, d)
if sign == -1:
s = '-%s' % s
return self.fix_minus(s)