Python matplotlib.ticker.FixedLocator() Examples
The following are 30
code examples of matplotlib.ticker.FixedLocator().
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: custom_scale.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 7 votes |
def set_default_locators_and_formatters(self, axis): """ Override to set up the locators and formatters to use with the scale. This is only required if the scale requires custom locators and formatters. Writing custom locators and formatters is rather outside the scope of this example, but there are many helpful examples in ``ticker.py``. In our case, the Mercator example uses a fixed locator from -90 to 90 degrees and a custom formatter class to put convert the radians to degrees and put a degree symbol after the value:: """ class DegreeFormatter(Formatter): def __call__(self, x, pos=None): return "%d\N{DEGREE SIGN}" % np.degrees(x) axis.set_major_locator(FixedLocator( np.radians(np.arange(-90, 90, 10)))) axis.set_major_formatter(DegreeFormatter()) axis.set_minor_formatter(DegreeFormatter())
Example #2
Source File: axis.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ # XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #3
Source File: colorbar.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def set_ticks(self, ticks, update_ticks=True): """ Set tick locations. Parameters ---------- ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance} If None, a default Locator will be used. update_ticks : {True, False}, optional If True, tick locations are updated immediately. If False, use :meth:`update_ticks` to manually update the ticks. """ if np.iterable(ticks): self.locator = ticker.FixedLocator(ticks, nbins=len(ticks)) else: self.locator = ticks if update_ticks: self.update_ticks() self.stale = True
Example #4
Source File: axis.py From coffeegrindsize with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ # XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #5
Source File: axis.py From CogAlg with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks Parameters ---------- ticks : sequence of floats minor : bool """ # XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #6
Source File: colorbar.py From CogAlg with MIT License | 6 votes |
def __init__(self, ax, mappable, **kw): # Ensure mappable.norm.vmin, vmax are set when colorbar is called, even # if mappable.draw has not yet been called. This will not change vmin, # vmax if they are already set. mappable.autoscale_None() self.mappable = mappable kw['cmap'] = mappable.cmap kw['norm'] = mappable.norm kw['alpha'] = mappable.get_alpha() if isinstance(mappable, contour.ContourSet): CS = mappable kw['boundaries'] = CS._levels kw['values'] = CS.cvalues kw['extend'] = CS.extend #kw['ticks'] = CS._levels kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10)) kw['filled'] = CS.filled ColorbarBase.__init__(self, ax, **kw) if not CS.filled: self.add_lines(CS) else: ColorbarBase.__init__(self, ax, **kw)
Example #7
Source File: colorbar.py From Computable with MIT License | 6 votes |
def __init__(self, ax, mappable, **kw): mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax # are set when colorbar is called, # even if mappable.draw has not yet # been called. This will not change # vmin, vmax if they are already set. self.mappable = mappable kw['cmap'] = mappable.cmap kw['norm'] = mappable.norm kw['alpha'] = mappable.get_alpha() if isinstance(mappable, contour.ContourSet): CS = mappable kw['boundaries'] = CS._levels kw['values'] = CS.cvalues kw['extend'] = CS.extend #kw['ticks'] = CS._levels kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10)) kw['filled'] = CS.filled ColorbarBase.__init__(self, ax, **kw) if not CS.filled: self.add_lines(CS) else: ColorbarBase.__init__(self, ax, **kw)
Example #8
Source File: colorbar.py From Computable with MIT License | 6 votes |
def _select_locator(self, formatter): ''' select a suitable locator ''' 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() else: locator = ticker.MaxNLocator(nbins=5) else: b = self._boundaries[self._inside] locator = ticker.FixedLocator(b) #, nbins=10) self.cbar_axis.set_major_locator(locator)
Example #9
Source File: colorbar.py From Computable with MIT License | 6 votes |
def __init__(self, ax, mappable, **kw): mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax # are set when colorbar is called, # even if mappable.draw has not yet # been called. This will not change # vmin, vmax if they are already set. self.mappable = mappable kw['cmap'] = mappable.cmap kw['norm'] = mappable.norm kw['alpha'] = mappable.get_alpha() if isinstance(mappable, contour.ContourSet): CS = mappable kw['boundaries'] = CS._levels kw['values'] = CS.cvalues kw['extend'] = CS.extend #kw['ticks'] = CS._levels kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10)) kw['filled'] = CS.filled ColorbarBase.__init__(self, ax, **kw) if not CS.filled: self.add_lines(CS) else: ColorbarBase.__init__(self, ax, **kw)
Example #10
Source File: axis.py From Computable with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ ### XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #11
Source File: colorbar.py From twitter-stock-recommendation with MIT License | 6 votes |
def set_ticks(self, ticks, update_ticks=True): """ Set tick locations. Parameters ---------- ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance} If None, a default Locator will be used. update_ticks : {True, False}, optional If True, tick locations are updated immediately. If False, use :meth:`update_ticks` to manually update the ticks. """ if cbook.iterable(ticks): self.locator = ticker.FixedLocator(ticks, nbins=len(ticks)) else: self.locator = ticks if update_ticks: self.update_ticks() self.stale = True
Example #12
Source File: colorbar.py From CogAlg with MIT License | 6 votes |
def set_ticks(self, ticks, update_ticks=True): """ Set tick locations. Parameters ---------- ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance} If None, a default Locator will be used. update_ticks : {True, False}, optional If True, tick locations are updated immediately. If False, use :meth:`update_ticks` to manually update the ticks. """ if np.iterable(ticks): self.locator = ticker.FixedLocator(ticks, nbins=len(ticks)) else: self.locator = ticks if update_ticks: self.update_ticks() self.stale = True
Example #13
Source File: axis.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks Parameters ---------- ticks : sequence of floats minor : bool """ # XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #14
Source File: colorbar.py From matplotlib-4-abaqus with MIT License | 6 votes |
def __init__(self, ax, mappable, **kw): mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax # are set when colorbar is called, # even if mappable.draw has not yet # been called. This will not change # vmin, vmax if they are already set. self.mappable = mappable kw['cmap'] = mappable.cmap kw['norm'] = mappable.norm kw['alpha'] = mappable.get_alpha() if isinstance(mappable, contour.ContourSet): CS = mappable kw['boundaries'] = CS._levels kw['values'] = CS.cvalues kw['extend'] = CS.extend #kw['ticks'] = CS._levels kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10)) kw['filled'] = CS.filled ColorbarBase.__init__(self, ax, **kw) if not CS.filled: self.add_lines(CS) else: ColorbarBase.__init__(self, ax, **kw)
Example #15
Source File: axis.py From matplotlib-4-abaqus with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ ### XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #16
Source File: colorbar.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def set_ticks(self, ticks, update_ticks=True): """ Set tick locations. Parameters ---------- ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance} If None, a default Locator will be used. update_ticks : {True, False}, optional If True, tick locations are updated immediately. If False, use :meth:`update_ticks` to manually update the ticks. """ if cbook.iterable(ticks): self.locator = ticker.FixedLocator(ticks, nbins=len(ticks)) else: self.locator = ticks if update_ticks: self.update_ticks() self.stale = True
Example #17
Source File: colorbar.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def __init__(self, ax, mappable, **kw): mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax # are set when colorbar is called, # even if mappable.draw has not yet # been called. This will not change # vmin, vmax if they are already set. self.mappable = mappable kw['cmap'] = mappable.cmap kw['norm'] = mappable.norm kw['alpha'] = mappable.get_alpha() if isinstance(mappable, contour.ContourSet): CS = mappable kw['boundaries'] = CS._levels kw['values'] = CS.cvalues kw['extend'] = CS.extend #kw['ticks'] = CS._levels kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10)) kw['filled'] = CS.filled ColorbarBase.__init__(self, ax, **kw) if not CS.filled: self.add_lines(CS) else: ColorbarBase.__init__(self, ax, **kw)
Example #18
Source File: axis.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ # XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #19
Source File: colorbar.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def set_ticks(self, ticks, update_ticks=True): """ Set tick locations. Parameters ---------- ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance} If None, a default Locator will be used. update_ticks : {True, False}, optional If True, tick locations are updated immediately. If False, use :meth:`update_ticks` to manually update the ticks. """ if cbook.iterable(ticks): self.locator = ticker.FixedLocator(ticks, nbins=len(ticks)) else: self.locator = ticks if update_ticks: self.update_ticks() self.stale = True
Example #20
Source File: colorbar.py From GraphicDesignPatternByPython with MIT License | 6 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) _log.debug('locator: %r', locator) return locator, formatter
Example #21
Source File: axis.py From neural-network-animation with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ ### XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #22
Source File: axis.py From ImageFusion with MIT License | 6 votes |
def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks ACCEPTS: sequence of floats """ ### XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) if len(ticks) > 1: xleft, xright = self.get_view_interval() if xright > xleft: self.set_view_interval(min(ticks), max(ticks)) else: self.set_view_interval(max(ticks), min(ticks)) if minor: self.set_minor_locator(mticker.FixedLocator(ticks)) return self.get_minor_ticks(len(ticks)) else: self.set_major_locator(mticker.FixedLocator(ticks)) return self.get_major_ticks(len(ticks))
Example #23
Source File: colorbar.py From matplotlib-4-abaqus with MIT License | 6 votes |
def __init__(self, ax, mappable, **kw): mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax # are set when colorbar is called, # even if mappable.draw has not yet # been called. This will not change # vmin, vmax if they are already set. self.mappable = mappable kw['cmap'] = mappable.cmap kw['norm'] = mappable.norm kw['alpha'] = mappable.get_alpha() if isinstance(mappable, contour.ContourSet): CS = mappable kw['boundaries'] = CS._levels kw['values'] = CS.cvalues kw['extend'] = CS.extend #kw['ticks'] = CS._levels kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10)) kw['filled'] = CS.filled ColorbarBase.__init__(self, ax, **kw) if not CS.filled: self.add_lines(CS) else: ColorbarBase.__init__(self, ax, **kw)
Example #24
Source File: colorbar.py From matplotlib-4-abaqus with MIT License | 6 votes |
def _select_locator(self, formatter): ''' select a suitable locator ''' 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() else: locator = ticker.MaxNLocator(nbins=5) else: b = self._boundaries[self._inside] locator = ticker.FixedLocator(b) #, nbins=10) self.cbar_axis.set_major_locator(locator)
Example #25
Source File: colorbar.py From coffeegrindsize with MIT License | 6 votes |
def set_ticks(self, ticks, update_ticks=True): """ Set tick locations. Parameters ---------- ticks : {None, sequence, :class:`~matplotlib.ticker.Locator` instance} If None, a default Locator will be used. update_ticks : {True, False}, optional If True, tick locations are updated immediately. If False, use :meth:`update_ticks` to manually update the ticks. """ if cbook.iterable(ticks): self.locator = ticker.FixedLocator(ticks, nbins=len(ticks)) else: self.locator = ticks if update_ticks: self.update_ticks() self.stale = True
Example #26
Source File: colorbar.py From ImageFusion with MIT License | 5 votes |
def set_ticks(self, ticks, update_ticks=True): """ set tick locations. Tick locations are updated immediately unless update_ticks is *False*. To manually update the ticks, call *update_ticks* method explicitly. """ if cbook.iterable(ticks): self.locator = ticker.FixedLocator(ticks, nbins=len(ticks)) else: self.locator = ticks if update_ticks: self.update_ticks()
Example #27
Source File: colorbar.py From coffeegrindsize with MIT License | 5 votes |
def __init__(self, ax, mappable, **kw): # Ensure the given mappable's norm has appropriate vmin and vmax set # even if mappable.draw has not yet been called. mappable.autoscale_None() self.mappable = mappable kw['cmap'] = cmap = mappable.cmap kw['norm'] = norm = mappable.norm if isinstance(mappable, contour.ContourSet): CS = mappable kw['alpha'] = mappable.get_alpha() kw['boundaries'] = CS._levels kw['values'] = CS.cvalues kw['extend'] = CS.extend #kw['ticks'] = CS._levels kw.setdefault('ticks', ticker.FixedLocator(CS.levels, nbins=10)) kw['filled'] = CS.filled ColorbarBase.__init__(self, ax, **kw) if not CS.filled: self.add_lines(CS) else: if getattr(cmap, 'colorbar_extend', False) is not False: kw.setdefault('extend', cmap.colorbar_extend) if isinstance(mappable, martist.Artist): kw['alpha'] = mappable.get_alpha() ColorbarBase.__init__(self, ax, **kw)
Example #28
Source File: _visualization_2d.py From gempy with GNU Lesser General Public License v3.0 | 5 votes |
def plot_section_by_name(self, section_name, show_data=True, show_faults=True, show_topo=True, show_all_data=False, contourplot=True, radius='default', **kwargs): if self.model.solutions.sections is None: raise AttributeError('no sections for plotting defined') if section_name not in self.model._grid.sections.names: raise AttributeError(f'Section "{section_name}" is not defined. ' f'Available sections for plotting: {self.model._grid.sections.names}') j = np.where(self.model._grid.sections.names == section_name)[0][0] l0, l1 = self.model._grid.sections.get_section_args(section_name) shape = self.model._grid.sections.resolution[j] image = self.model.solutions.sections[0][0][l0:l1].reshape(shape[0], shape[1]).T extent = [0, self.model._grid.sections.dist[j][0], self.model._grid.regular_grid.extent[4], self.model._grid.regular_grid.extent[5]] if show_data: self.plot_section_data(section_name=section_name, show_all_data=show_all_data, radius=radius) axes = plt.gca() axes.imshow(image, origin='lower', zorder=-100, cmap=self._cmap, norm=self._norm, extent=extent) if show_faults and not contourplot: self.extract_section_lines(section_name, axes, faults_only=True) else: self.extract_section_lines(section_name, axes, faults_only=False) if show_topo: if self.model._grid.topography is not None: alpha = kwargs.get('alpha', 1) xy = self.make_topography_overlay_4_sections(j) axes.fill(xy[:, 0], xy[:, 1], 'k', zorder=10, alpha=alpha) labels, axname = self._make_section_xylabels(section_name, len(axes.get_xticklabels()) - 1) pos_list = np.linspace(0, self.model._grid.sections.dist[j], len(labels)) axes.xaxis.set_major_locator(FixedLocator(nbins=len(labels), locs=pos_list)) axes.xaxis.set_major_formatter(FixedFormatter((labels))) axes.set(title=self.model._grid.sections.names[j], xlabel=axname, ylabel='Z')
Example #29
Source File: _visualization_2d.py From gempy with GNU Lesser General Public License v3.0 | 5 votes |
def plot_section_scalarfield(self, section_name, sn, levels=50, show_faults=True, show_topo=True, lithback=True): if self.model.solutions.sections is None: raise AttributeError('no sections for plotting defined') if self.model._grid.topography is None: show_topo = False shapes = self.model._grid.sections.resolution fig = plt.figure(figsize=(16, 10)) axes = fig.add_subplot(1, 1, 1) j = np.where(self.model._grid.sections.names == section_name)[0][0] l0, l1 = self.model._grid.sections.get_section_args(section_name) if show_faults: self.extract_section_fault_lines(section_name, zorder=9) if show_topo: xy = self.make_topography_overlay_4_sections(j) axes.fill(xy[:, 0], xy[:, 1], 'k', zorder=10) axes.contour(self.model.solutions.sections[1][sn][l0:l1].reshape(shapes[j][0], shapes[j][1]).T, # origin='lower', levels=levels, cmap='autumn', extent=[0, self.model._grid.sections.dist[j], self.model._grid.regular_grid.extent[4], self.model._grid.regular_grid.extent[5]], zorder=8) axes.set_aspect('equal') if lithback: axes.imshow(self.model.solutions.sections[0][0][l0:l1].reshape(shapes[j][0], shapes[j][1]).T, origin='lower', cmap=self._cmap, norm=self._norm, extent=[0, self.model._grid.sections.dist[j], self.model._grid.regular_grid.extent[4], self.model._grid.regular_grid.extent[5]]) labels, axname = self._make_section_xylabels(section_name, len(axes.get_xticklabels())) pos_list = np.linspace(0, self.model._grid.sections.dist[j], len(labels)) axes.xaxis.set_major_locator(FixedLocator(nbins=len(labels), locs=pos_list)) axes.xaxis.set_major_formatter(FixedFormatter((labels))) axes.set(title=self.model._grid.sections.names[j], xlabel=axname, ylabel='Z')
Example #30
Source File: test_ticker.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_set_params(self): """ Create fixed locator with 5 nbins, and change it to something else. See if change was successful. Should not exception. """ fixed = mticker.FixedLocator(range(0, 24), nbins=5) fixed.set_params(nbins=7) assert fixed.nbins == 7