本文整理汇总了Python中matplotlib.ticker.LogFormatterSciNotation方法的典型用法代码示例。如果您正苦于以下问题:Python ticker.LogFormatterSciNotation方法的具体用法?Python ticker.LogFormatterSciNotation怎么用?Python ticker.LogFormatterSciNotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.ticker
的用法示例。
在下文中一共展示了ticker.LogFormatterSciNotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: minorticks_on
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterSciNotation [as 别名]
def minorticks_on(self):
"""
Turns on the minor ticks on the colorbar without extruding
into the "extend regions".
"""
ax = self.ax
long_axis = ax.yaxis if self.orientation == 'vertical' else ax.xaxis
if long_axis.get_scale() == 'log':
long_axis.set_minor_locator(_ColorbarLogLocator(self, base=10.,
subs='auto'))
long_axis.set_minor_formatter(ticker.LogFormatterSciNotation())
else:
long_axis.set_minor_locator(_ColorbarAutoMinorLocator(self))
示例2: update_ticks
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterSciNotation [as 别名]
def update_ticks(self):
"""
Force the update of the ticks and ticklabels. This must be
called whenever the tick locator and/or tick formatter changes.
"""
ax = self.ax
# get the locator and formatter. Defaults to
# self.locator if not None..
locator, formatter = self._get_ticker_locator_formatter()
if self.orientation == 'vertical':
long_axis, short_axis = ax.yaxis, ax.xaxis
else:
long_axis, short_axis = ax.xaxis, ax.yaxis
if self._use_auto_colorbar_locator():
_log.debug('Using auto colorbar locator on colorbar')
_log.debug('locator: %r', locator)
long_axis.set_major_locator(locator)
long_axis.set_major_formatter(formatter)
if type(self.norm) == colors.LogNorm:
long_axis.set_minor_locator(_ColorbarLogLocator(self,
base=10., subs='auto'))
long_axis.set_minor_formatter(
ticker.LogFormatterSciNotation()
)
else:
_log.debug('Using fixed locator on colorbar')
ticks, ticklabels, offset_string = self._ticker(locator, formatter)
long_axis.set_ticks(ticks)
long_axis.set_ticklabels(ticklabels)
long_axis.get_major_formatter().set_offset_string(offset_string)
示例3: test_basic
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterSciNotation [as 别名]
def test_basic(self, base, value, expected):
formatter = mticker.LogFormatterSciNotation(base=base)
formatter.sublabel = {1, 2, 5, 1.2}
with matplotlib.rc_context({'text.usetex': False}):
assert formatter(value) == expected
示例4: _get_ticker_locator_formatter
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterSciNotation [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
示例5: exportSingleParameterLossChart
# 需要导入模块: from matplotlib import ticker [as 别名]
# 或者: from matplotlib.ticker import LogFormatterSciNotation [as 别名]
def exportSingleParameterLossChart(self, fileName, results, parameter, valueKey='loss', title='Loss Chart', cutoff=1.0, numBuckets=None, reduction='mean'):
values, linearTrendLine, exponentialTrendLine = self.computeParameterResultValues(results, parameter, valueKey, cutoff, numBuckets, bucket_reduction=reduction)
if self.singleParameterLossFigure is None:
fig, ax = plt.subplots()
self.singleParameterLossFigure = fig
self.singleParameterLossAxes = ax
else:
fig = self.singleParameterLossFigure
ax = self.singleParameterLossAxes
ax.clear()
fig.suptitle(title + " for " + parameter.root[5:])
if parameter.config.get('scaling', 'linear') == 'logarithmic':
ax.set_xscale('log')
else:
ax.set_xscale('linear')
xCoords = [value[parameter.root[5:]] for value in values]
yCoords = [value[valueKey] for value in values]
ax.set_xlabel(parameter.root[5:])
ax.set_ylabel(valueKey)
ax.scatter(xCoords, yCoords)
minVal = parameter.config.get('min')
maxVal = parameter.config.get('max')
if (minVal > 0.001 and minVal < 10000 and maxVal > 0.001 and maxVal < 10000):
ax.xaxis.set_minor_formatter(mticker.ScalarFormatter())
ax.xaxis.set_major_formatter(mticker.ScalarFormatter())
else:
ax.xaxis.set_minor_formatter(mticker.LogFormatterSciNotation())
ax.xaxis.set_major_formatter(mticker.LogFormatterSciNotation())
# Preserve the limits of the scatter graph when we apply the trend line
xlim = ax.get_xlim()
ylim = ax.get_ylim()
if linearTrendLine and exponentialTrendLine:
trendLineXCoords = [linearTrendLine[index][0] for index in range(len(linearTrendLine))]
ax.plot(trendLineXCoords, [(linearTrendLine[index][1], exponentialTrendLine[index][1]) for index in range(len(exponentialTrendLine))], color='red', linestyle='dashed')
elif linearTrendLine:
trendLineXCoords = [linearTrendLine[index][0] for index in range(len(linearTrendLine))]
ax.plot(trendLineXCoords, [linearTrendLine[index][1] for index in range(len(linearTrendLine))], color='red', linestyle='dashed')
elif exponentialTrendLine:
trendLineXCoords = [exponentialTrendLine[index][0] for index in range(len(linearTrendLine))]
ax.plot(trendLineXCoords, [exponentialTrendLine[index][1] for index in range(len(exponentialTrendLine))], color='red', linestyle='dashed')
ax.set_xlim(xlim)
ax.set_ylim(ylim)
fig.set_tight_layout(True)
fig.savefig(fileName, dpi=200)
plt.close(fig)