Python matplotlib.ticker.LogFormatterSciNotation() Examples
The following are 10
code examples of matplotlib.ticker.LogFormatterSciNotation().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.ticker
, or try the search function
.
Example #1
Source File: colorbar.py From Mastering-Elasticsearch-7.0 with MIT License | 5 votes |
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))
Example #2
Source File: colorbar.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #3
Source File: test_ticker.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #4
Source File: colorbar.py From coffeegrindsize with MIT License | 5 votes |
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)
Example #5
Source File: test_ticker.py From coffeegrindsize with MIT License | 5 votes |
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
Example #6
Source File: colorbar.py From CogAlg with MIT License | 5 votes |
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))
Example #7
Source File: test_ticker.py From twitter-stock-recommendation with MIT License | 5 votes |
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
Example #8
Source File: colorbar.py From Mastering-Elasticsearch-7.0 with MIT License | 4 votes |
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
Example #9
Source File: results_analyzer.py From hypermax with BSD 3-Clause "New" or "Revised" License | 4 votes |
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)
Example #10
Source File: colorbar.py From CogAlg with MIT License | 4 votes |
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