本文整理汇总了Python中matplotlib.ticker.SymmetricalLogLocator方法的典型用法代码示例。如果您正苦于以下问题:Python ticker.SymmetricalLogLocator方法的具体用法?Python ticker.SymmetricalLogLocator怎么用?Python ticker.SymmetricalLogLocator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.ticker
的用法示例。
在下文中一共展示了ticker.SymmetricalLogLocator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: minorticks_on
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import SymmetricalLogLocator [as 别名]
def minorticks_on(self):
"""
Display minor ticks on the axes.
Displaying minor ticks may reduce performance; you may turn them off
using `minorticks_off()` if drawing speed is a problem.
"""
for ax in (self.xaxis, self.yaxis):
scale = ax.get_scale()
if scale == 'log':
s = ax._scale
ax.set_minor_locator(mticker.LogLocator(s.base, s.subs))
elif scale == 'symlog':
s = ax._scale
ax.set_minor_locator(
mticker.SymmetricalLogLocator(s._transform, s.subs))
else:
ax.set_minor_locator(mticker.AutoMinorLocator())
示例2: _get_ticker_locator_formatter
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import SymmetricalLogLocator [as 别名]
def _get_ticker_locator_formatter(self):
"""
This code looks at the norm being used by the colorbar
and decides what locator and formatter to use. If ``locator`` has
already been set by hand, it just returns
``self.locator, self.formatter``.
"""
locator = self.locator
formatter = self.formatter
if locator is None:
if self.boundaries is None:
if isinstance(self.norm, colors.NoNorm):
nv = len(self._values)
base = 1 + int(nv / 10)
locator = ticker.IndexLocator(base=base, offset=0)
elif isinstance(self.norm, colors.BoundaryNorm):
b = self.norm.boundaries
locator = ticker.FixedLocator(b, nbins=10)
elif isinstance(self.norm, colors.LogNorm):
locator = _ColorbarLogLocator(self)
elif isinstance(self.norm, colors.SymLogNorm):
# The subs setting here should be replaced
# by logic in the locator.
locator = ticker.SymmetricalLogLocator(
subs=np.arange(1, 10),
linthresh=self.norm.linthresh,
base=10)
else:
if mpl.rcParams['_internal.classic_mode']:
locator = ticker.MaxNLocator()
else:
locator = _ColorbarAutoLocator(self)
else:
b = self._boundaries[self._inside]
locator = ticker.FixedLocator(b, nbins=10)
_log.debug('locator: %r', locator)
return locator, formatter
示例3: test_set_params
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import SymmetricalLogLocator [as 别名]
def test_set_params(self):
"""
Create symmetrical log locator with default subs =[1.0] numticks = 15,
and change it to something else.
See if change was successful.
Should not exception.
"""
sym = mticker.SymmetricalLogLocator(base=10, linthresh=1)
sym.set_params(subs=[2.0], numticks=8)
assert sym._subs == [2.0]
assert sym.numticks == 8
示例4: minorticks_on
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import SymmetricalLogLocator [as 别名]
def minorticks_on(self):
'Add autoscaling minor ticks to the axes.'
for ax in (self.xaxis, self.yaxis):
scale = ax.get_scale()
if scale == 'log':
s = ax._scale
ax.set_minor_locator(mticker.LogLocator(s.base, s.subs))
elif scale == 'symlog':
s = ax._scale
ax.set_minor_locator(
mticker.SymmetricalLogLocator(s._transform, s.subs))
else:
ax.set_minor_locator(mticker.AutoMinorLocator())
示例5: _get_ticker_locator_formatter
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import SymmetricalLogLocator [as 别名]
def _get_ticker_locator_formatter(self):
"""
This code looks at the norm being used by the colorbar
and decides what locator and formatter to use. If ``locator`` has
already been set by hand, it just returns
``self.locator, self.formatter``.
"""
locator = self.locator
formatter = self.formatter
if locator is None:
if self.boundaries is None:
if isinstance(self.norm, colors.NoNorm):
nv = len(self._values)
base = 1 + int(nv / 10)
locator = ticker.IndexLocator(base=base, offset=0)
elif isinstance(self.norm, colors.BoundaryNorm):
b = self.norm.boundaries
locator = ticker.FixedLocator(b, nbins=10)
elif isinstance(self.norm, colors.LogNorm):
locator = _ColorbarLogLocator(self)
elif isinstance(self.norm, colors.SymLogNorm):
# The subs setting here should be replaced
# by logic in the locator.
locator = ticker.SymmetricalLogLocator(
subs=np.arange(1, 10),
linthresh=self.norm.linthresh,
base=10)
else:
if mpl.rcParams['_internal.classic_mode']:
locator = ticker.MaxNLocator()
else:
locator = _ColorbarAutoLocator(self)
else:
b = self._boundaries[self._inside]
locator = ticker.FixedLocator(b, nbins=10)
if formatter is None:
if isinstance(self.norm, colors.LogNorm):
formatter = ticker.LogFormatterSciNotation()
elif isinstance(self.norm, colors.SymLogNorm):
formatter = ticker.LogFormatterSciNotation(
linthresh=self.norm.linthresh)
else:
formatter = ticker.ScalarFormatter()
else:
formatter = self.formatter
self.locator = locator
self.formatter = formatter
_log.debug('locator: %r', locator)
return locator, formatter
示例6: _ticker
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import SymmetricalLogLocator [as 别名]
def _ticker(self):
'''
Return the sequence of ticks (colorbar data locations),
ticklabels (strings), and the corresponding offset string.
'''
locator = self.locator
formatter = self.formatter
if locator is None:
if self.boundaries is None:
if isinstance(self.norm, colors.NoNorm):
nv = len(self._values)
base = 1 + int(nv / 10)
locator = ticker.IndexLocator(base=base, offset=0)
elif isinstance(self.norm, colors.BoundaryNorm):
b = self.norm.boundaries
locator = ticker.FixedLocator(b, nbins=10)
elif isinstance(self.norm, colors.LogNorm):
locator = ticker.LogLocator(subs='all')
elif isinstance(self.norm, colors.SymLogNorm):
# The subs setting here should be replaced
# by logic in the locator.
locator = ticker.SymmetricalLogLocator(
subs=np.arange(1, 10),
linthresh=self.norm.linthresh,
base=10)
else:
if mpl.rcParams['_internal.classic_mode']:
locator = ticker.MaxNLocator()
else:
locator = ticker.AutoLocator()
else:
b = self._boundaries[self._inside]
locator = ticker.FixedLocator(b, nbins=10)
if isinstance(self.norm, colors.NoNorm) and self.boundaries is None:
intv = self._values[0], self._values[-1]
else:
intv = self.vmin, self.vmax
locator.create_dummy_axis(minpos=intv[0])
formatter.create_dummy_axis(minpos=intv[0])
locator.set_view_interval(*intv)
locator.set_data_interval(*intv)
formatter.set_view_interval(*intv)
formatter.set_data_interval(*intv)
b = np.array(locator())
if isinstance(locator, ticker.LogLocator):
eps = 1e-10
b = b[(b <= intv[1] * (1 + eps)) & (b >= intv[0] * (1 - eps))]
else:
eps = (intv[1] - intv[0]) * 1e-10
b = b[(b <= intv[1] + eps) & (b >= intv[0] - eps)]
self._tick_data_values = b
ticks = self._locate(b)
formatter.set_locs(b)
ticklabels = [formatter(t, i) for i, t in enumerate(b)]
offset_string = formatter.get_offset()
return ticks, ticklabels, offset_string