matplotlib.ticker¶

Tick locating and formatting¶

This module contains classes to support completely configurable tick locating and formatting. Although the locators know nothing about major or minor ticks, they are used by the Axis class to support major and minor tick locating and formatting. Generic tick locators and formatters are provided, as well as domain specific custom ones.

Default Formatter¶

The default formatter identifies when the x-data being plotted is a small range on top of a large offset. To reduce the chances that the ticklabels overlap, the ticks are labeled as deltas from a fixed offset. For example:

ax.plot(np.arange(2000, 2010), range(10))


will have tick of 0-9 with an offset of +2e3. If this is not desired turn off the use of the offset on the default formatter:

ax.get_xaxis().get_major_formatter().set_useOffset(False)


set the rcParam axes.formatter.useoffset=False to turn it off globally, or set a different formatter.

Tick locating¶

The Locator class is the base class for all tick locators. The locators handle autoscaling of the view limits based on the data limits, and the choosing of tick locations. A useful semi-automatic tick locator is MultipleLocator. It is initialized with a base, e.g., 10, and it picks axis limits and ticks that are multiples of that base.

The Locator subclasses defined here are

AutoLocator
MaxNLocator with simple defaults. This is the default tick locator for most plotting.
MaxNLocator
Finds up to a max number of intervals with ticks at nice locations.
LinearLocator
Space ticks evenly from min to max.
LogLocator
Space ticks logarithmically from min to max.
MultipleLocator
Ticks and range are a multiple of base; either integer or float.
FixedLocator
Tick locations are fixed.
IndexLocator
Locator for index plots (e.g., where x = range(len(y))).
NullLocator
No ticks.
SymmetricalLogLocator
Locator for use with with the symlog norm; works like LogLocator for the part outside of the threshold and adds 0 if inside the limits.
LogitLocator
Locator for logit scaling.
OldAutoLocator
Choose a MultipleLocator and dynamically reassign it for intelligent ticking during navigation.
AutoMinorLocator
Locator for minor ticks when the axis is linear and the major ticks are uniformly spaced. Subdivides the major tick interval into a specified number of minor intervals, defaulting to 4 or 5 depending on the major interval.

There are a number of locators specialized for date locations - see the dates module.

You can define your own locator by deriving from Locator. You must override the __call__ method, which returns a sequence of locations, and you will probably want to override the autoscale method to set the view limits from the data limits.

If you want to override the default locator, use one of the above or a custom locator and pass it to the x or y axis instance. The relevant methods are:

ax.xaxis.set_major_locator(xmajor_locator)
ax.xaxis.set_minor_locator(xminor_locator)
ax.yaxis.set_major_locator(ymajor_locator)
ax.yaxis.set_minor_locator(yminor_locator)


The default minor locator is NullLocator, i.e., no minor ticks on by default.

Tick formatting¶

Tick formatting is controlled by classes derived from Formatter. The formatter operates on a single tick value and returns a string to the axis.

NullFormatter
No labels on the ticks.
IndexFormatter
Set the strings from a list of labels.
FixedFormatter
Set the strings manually for the labels.
FuncFormatter
User defined function sets the labels.
StrMethodFormatter
Use string format method.
FormatStrFormatter
Use an old-style sprintf format string.
ScalarFormatter
Default formatter for scalars: autopick the format string.
LogFormatter
Formatter for log axes.
LogFormatterExponent
Format values for log axis using exponent = log_base(value).
LogFormatterMathtext
Format values for log axis using exponent = log_base(value) using Math text.
LogFormatterSciNotation
Format values for log axis using scientific notation.
LogitFormatter
Probability formatter.
EngFormatter
Format labels in engineering notation
PercentFormatter
Format labels as a percentage

You can derive your own formatter from the Formatter base class by simply overriding the __call__ method. The formatter class has access to the axis view and data limits.

To control the major and minor tick label formats, use one of the following methods:

ax.xaxis.set_major_formatter(xmajor_formatter)
ax.xaxis.set_minor_formatter(xminor_formatter)
ax.yaxis.set_major_formatter(ymajor_formatter)
ax.yaxis.set_minor_formatter(yminor_formatter)


See Major and minor ticks for an example of setting major and minor ticks. See the matplotlib.dates module for more information and examples of using date locators and formatters.

class matplotlib.ticker.TickHelper[source]

Bases: object

axis = None
create_dummy_axis(self, **kwargs)[source]
set_axis(self, axis)[source]
set_bounds(self, vmin, vmax)[source]
set_data_interval(self, vmin, vmax)[source]
set_view_interval(self, vmin, vmax)[source]
class matplotlib.ticker.Formatter[source]

Create a string based on a tick value and location.

static fix_minus(s)[source]

Some classes may want to replace a hyphen for minus with the proper unicode symbol (U+2212) for typographical correctness. This is a helper method to perform such a replacement when it is enabled via rcParams["axes.unicode_minus"] (default: True).

format_data(self, value)[source]

Returns the full string representation of the value with the position unspecified.

format_data_short(self, value)[source]

Return a short string version of the tick value.

Defaults to the position-independent long value.

format_ticks(self, values)[source]

Return the tick labels for all the ticks at once.

get_offset(self)[source]
locs = []
set_locs(self, locs)[source]
class matplotlib.ticker.FixedFormatter(seq)[source]

Return fixed strings for tick labels based only on position, not value.

Set the sequence of strings that will be used for labels.

get_offset(self)[source]
set_offset_string(self, ofs)[source]
class matplotlib.ticker.NullFormatter[source]

Always return the empty string.

class matplotlib.ticker.FuncFormatter(func)[source]

Use a user-defined function for formatting.

The function should take in two inputs (a tick value x and a position pos), and return a string containing the corresponding tick label.

class matplotlib.ticker.FormatStrFormatter(fmt)[source]

Use an old-style ('%' operator) format string to format the tick.

The format string should have a single variable format (%) in it. It will be applied to the value (not the position) of the tick.

class matplotlib.ticker.StrMethodFormatter(fmt)[source]

Use a new-style format string (as used by str.format()) to format the tick.

The field used for the value must be labeled x and the field used for the position must be labeled pos.

class matplotlib.ticker.ScalarFormatter(useOffset=None, useMathText=None, useLocale=None)[source]

Format tick values as a number.

Tick value is interpreted as a plain old number. If useOffset==True and the data range is much smaller than the data average, then an offset will be determined such that the tick labels are meaningful. Scientific notation is used for data < 10^-n or data >= 10^m, where n and m are the power limits set using set_powerlimits((n, m)). The defaults for these are controlled by the axes.formatter.limits rc parameter.

format_data(self, value)[source]

Return a formatted string representation of a number.

format_data_short(self, value)[source]

Return a short string version of the tick value.

Defaults to the position-independent long value.

get_offset(self)[source]

Return scientific notation, plus offset.

get_useLocale(self)[source]
get_useMathText(self)[source]
get_useOffset(self)[source]
pprint_val(self, x)[source]

[Deprecated]

Notes

Deprecated since version 3.1:

set_locs(self, locs)[source]

Set the locations of the ticks.

set_powerlimits(self, lims)[source]

Sets size thresholds for scientific notation.

Parameters: lims(min_exp, max_exp)A tuple containing the powers of 10 that determine the switchover threshold. Numbers below 10**min_exp and above 10**max_exp will be displayed in scientific notation. For example, formatter.set_powerlimits((-3, 4)) sets the pre-2007 default in which scientific notation is used for numbers less than 1e-3 or greater than 1e4.
set_scientific(self, b)[source]

Turn scientific notation on or off.

set_useLocale(self, val)[source]
set_useMathText(self, val)[source]
set_useOffset(self, val)[source]
property useLocale
property useMathText
property useOffset
class matplotlib.ticker.LogFormatter(base=10.0, labelOnlyBase=False, minor_thresholds=None, linthresh=None)[source]

Base class for formatting ticks on a log or symlog scale.

It may be instantiated directly, or subclassed.

Parameters: basefloat, optional, default: 10.Base of the logarithm used in all calculations. labelOnlyBasebool, optional, default: FalseIf True, label ticks only at integer powers of base. This is normally True for major ticks and False for minor ticks. minor_thresholds(subset, all), optional, default: (1, 0.4)If labelOnlyBase is False, these two numbers control the labeling of ticks that are not at integer powers of base; normally these are the minor ticks. The controlling parameter is the log of the axis data range. In the typical case where base is 10 it is the number of decades spanned by the axis, so we can call it 'numdec'. If numdec <= all, all minor ticks will be labeled. If all < numdec <= subset, then only a subset of minor ticks will be labeled, so as to avoid crowding. If numdec > subset then no minor ticks will be labeled. linthreshNone or float, optional, default: NoneIf a symmetric log scale is in use, its linthresh parameter must be supplied here.

Notes

The set_locs method must be called to enable the subsetting logic controlled by the minor_thresholds parameter.

In some cases such as the colorbar, there is no distinction between major and minor ticks; the tick locations might be set manually, or by a locator that puts ticks at integer powers of base and at intermediate locations. For this situation, disable the minor_thresholds logic by using minor_thresholds=(np.inf, np.inf), so that all ticks will be labeled.

To disable labeling of minor ticks when 'labelOnlyBase' is False, use minor_thresholds=(0, 0). This is the default for the "classic" style.

Examples

To label a subset of minor ticks when the view limits span up to 2 decades, and all of the ticks when zoomed in to 0.5 decades or less, use minor_thresholds=(2, 0.5).

To label all minor ticks when the view limits span up to 1.5 decades, use minor_thresholds=(1.5, 1.5).

base(self, base)[source]

Change the base for labeling.

Warning

Should always match the base used for LogLocator

format_data(self, value)[source]

Returns the full string representation of the value with the position unspecified.

format_data_short(self, value)[source]

Return a short string version of the tick value.

Defaults to the position-independent long value.

label_minor(self, labelOnlyBase)[source]

Switch minor tick labeling on or off.

Parameters: labelOnlyBaseboolIf True, label ticks only at integer powers of base.
pprint_val(self, *args, **kwargs)[source]

[Deprecated]

Notes

Deprecated since version 3.1:

set_locs(self, locs=None)[source]

Use axis view limits to control which ticks are labeled.

The locs parameter is ignored in the present algorithm.

class matplotlib.ticker.LogFormatterExponent(base=10.0, labelOnlyBase=False, minor_thresholds=None, linthresh=None)[source]

Format values for log axis using exponent = log_base(value).

class matplotlib.ticker.LogFormatterMathtext(base=10.0, labelOnlyBase=False, minor_thresholds=None, linthresh=None)[source]

Format values for log axis using exponent = log_base(value).

class matplotlib.ticker.IndexFormatter(labels)[source]

Format the position x to the nearest i-th label where i = int(x + 0.5). Positions where i < 0 or i > len(list) have no tick labels.

Parameters: labelslistList of labels.
class matplotlib.ticker.LogFormatterSciNotation(base=10.0, labelOnlyBase=False, minor_thresholds=None, linthresh=None)[source]

Format values following scientific notation in a logarithmic axis.

class matplotlib.ticker.LogitFormatter(*, use_overline=False, one_half='\frac{1}{2}', minor=False, minor_threshold=25, minor_number=6)[source]

Probability formatter (using Math text).

Parameters: use_overlinebool, default: FalseIf x > 1/2, with x = 1-v, indicate if x should be displayed as $overline{v}$. The default is to display $1-v$. one_halfstr, default: r"frac{1}{2}"The string used to represent 1/2. minorbool, default: FalseIndicate if the formatter is formatting minor ticks or not. Basically minor ticks are not labelled, except when only few ticks are provided, ticks with most space with neighbor ticks are labelled. See other parameters to change the default behavior. minor_thresholdint, default: 25Maximum number of locs for labelling some minor ticks. This parameter have no effect if minor is False. minor_numberint, default: 6Number of ticks which are labelled when the number of ticks is below the threshold.
format_data_short(self, value)[source]

Return a short formatted string representation of a number.

set_locs(self, locs)[source]
set_minor_number(self, minor_number)[source]

Set the number of minor ticks to label when some minor ticks are labelled.

Parameters: minor_numberintNumber of ticks which are labelled when the number of ticks is below the threshold.
set_minor_threshold(self, minor_threshold)[source]

Set the threshold for labelling minors ticks.

Parameters: minor_thresholdintMaximum number of locations for labelling some minor ticks. This parameter have no effect if minor is False.
set_one_half(self, one_half)[source]

Set the way one half is displayed.

one_halfstr, default: r"frac{1}{2}"
The string used to represent 1/2.
use_overline(self, use_overline)[source]

Switch display mode with overline for labelling p>1/2.

Parameters: use_overlinebool, default: FalseIf x > 1/2, with x = 1-v, indicate if x should be displayed as $overline{v}$. The default is to display $1-v$.
class matplotlib.ticker.EngFormatter(unit='', places=None, sep=' ', *, usetex=None, useMathText=None)[source]

Formats axis values using engineering prefixes to represent powers of 1000, plus a specified unit, e.g., 10 MHz instead of 1e7.

Parameters: unitstr (default: "")Unit symbol to use, suitable for use with single-letter representations of powers of 1000. For example, 'Hz' or 'm'. placesint (default: None)Precision with which to display the number, specified in digits after the decimal point (there will be between one and three digits before the decimal point). If it is None, the formatting falls back to the floating point format '%g', which displays up to 6 significant digits, i.e. the equivalent value for places varies between 0 and 5 (inclusive). sepstr (default: " ")Separator used between the value and the prefix/unit. For example, one get '3.14 mV' if sep is " " (default) and '3.14mV' if sep is "". Besides the default behavior, some other useful options may be: sep="" to append directly the prefix/unit to the value; sep="\N{THIN SPACE}" (U+2009); sep="\N{NARROW NO-BREAK SPACE}" (U+202F); sep="\N{NO-BREAK SPACE}" (U+00A0). usetexbool (default: None)To enable/disable the use of TeX's math mode for rendering the numbers in the formatter. useMathTextbool (default: None)To enable/disable the use mathtext for rendering the numbers in the formatter.
ENG_PREFIXES = {-24: 'y', -21: 'z', -18: 'a', -15: 'f', -12: 'p', -9: 'n', -6: 'µ', -3: 'm', 0: '', 3: 'k', 6: 'M', 9: 'G', 12: 'T', 15: 'P', 18: 'E', 21: 'Z', 24: 'Y'}
format_eng(self, num)[source]

Formats a number in engineering notation, appending a letter representing the power of 1000 of the original number. Some examples:

>>> format_eng(0)       # for self.places = 0
'0'

>>> format_eng(1000000) # for self.places = 1
'1.0 M'

>>> format_eng("-1e-6") # for self.places = 2
'-1.00 µ'

get_useMathText(self)[source]
get_usetex(self)[source]
set_useMathText(self, val)[source]
set_usetex(self, val)[source]
property useMathText
property usetex
class matplotlib.ticker.PercentFormatter(xmax=100, decimals=None, symbol='%', is_latex=False)[source]

Format numbers as a percentage.

Parameters: xmaxfloatDetermines how the number is converted into a percentage. xmax is the data value that corresponds to 100%. Percentages are computed as x / xmax * 100. So if the data is already scaled to be percentages, xmax will be 100. Another common situation is where xmax is 1.0. decimalsNone or intThe number of decimal places to place after the point. If None (the default), the number will be computed automatically. symbolstr or NoneA string that will be appended to the label. It may be None or empty to indicate that no symbol should be used. LaTeX special characters are escaped in symbol whenever latex mode is enabled, unless is_latex is True. is_latexboolIf False, reserved LaTeX characters in symbol will be escaped.
convert_to_pct(self, x)[source]
format_pct(self, x, display_range)[source]

Formats the number as a percentage number with the correct number of decimals and adds the percent symbol, if any.

If self.decimals is None, the number of digits after the decimal point is set based on the display_range of the axis as follows:

 display_range decimals sample >50 0 x = 34.5 => 35% >5 1 x = 34.5 => 34.5% >0.5 2 x = 34.5 => 34.50% ... ... ...

This method will not be very good for tiny axis ranges or extremely large ones. It assumes that the values on the chart are percentages displayed on a reasonable scale.

property symbol

The configured percent symbol as a string.

If LaTeX is enabled via rcParams["text.usetex"] (default: False), the special characters {'#', '\$', '%', '&', '~', '_', '^', '\', '{', '}'} are automatically escaped in the string.

class matplotlib.ticker.OldScalarFormatter[source]

Tick location is a plain old number.

pprint_val(self, x, d)[source]

[Deprecated] Formats the value x based on the size of the axis range d.

Notes

Deprecated since version 3.1.

class matplotlib.ticker.Locator[source]

Determine the tick locations;

Note that the same locator should not be used across multiple Axis because the locator stores references to the Axis data and view limits.

MAXTICKS = 1000
autoscale(self)[source]

[Deprecated] Autoscale the view limits.

Notes

Deprecated since version 3.2.

nonsingular(self, v0, v1)[source]

Adjust a range as needed to avoid singularities.

This method gets called during autoscaling, with (v0, v1) set to the data limits on the axes if the axes contains any data, or (-inf, +inf) if not.

• If v0 == v1 (possibly up to some floating point slop), this method returns an expanded interval around this value.
• If (v0, v1) == (-inf, +inf), this method returns appropriate default view limits.
• Otherwise, (v0, v1) is returned without modification.
pan(self, numsteps)[source]

Pan numticks (can be positive or negative)

raise_if_exceeds(self, locs)[source]

Log at WARNING level if locs is longer than Locator.MAXTICKS.

This is intended to be called immediately before returning locs from __call__ to inform users in case their Locator returns a huge number of ticks, causing Matplotlib to run out of memory.

The "strange" name of this method dates back to when it would raise an exception instead of emitting a log.

refresh(self)[source]

Refresh internal information based on current limits.

set_params(self, **kwargs)[source]

Do nothing, and raise a warning. Any locator class not supporting the set_params() function will call this.

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

view_limits(self, vmin, vmax)[source]

Select a scale for the range from vmin to vmax.

Subclasses should override this method to change locator behaviour.

zoom(self, direction)[source]

Zoom in/out on axis; if direction is >0 zoom in, else zoom out

class matplotlib.ticker.IndexLocator(base, offset)[source]

Place a tick on every multiple of some base number of points plotted, e.g., on every 5th point. It is assumed that you are doing index plotting; i.e., the axis is 0, len(data). This is mainly useful for x ticks.

Place ticks every base data point, starting at offset.

set_params(self, base=None, offset=None)[source]

Set parameters within this locator

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

class matplotlib.ticker.FixedLocator(locs, nbins=None)[source]

Tick locations are fixed. If nbins is not None, the array of possible positions will be subsampled to keep the number of ticks <= nbins +1. The subsampling will be done so as to include the smallest absolute value; for example, if zero is included in the array of possibilities, then it is guaranteed to be one of the chosen ticks.

set_params(self, nbins=None)[source]

Set parameters within this locator.

tick_values(self, vmin, vmax)[source]

" Return the locations of the ticks.

Note

Because the values are fixed, vmin and vmax are not used in this method.

class matplotlib.ticker.NullLocator[source]

No ticks

tick_values(self, vmin, vmax)[source]

" Return the locations of the ticks.

Note

Because the values are Null, vmin and vmax are not used in this method.

class matplotlib.ticker.LinearLocator(numticks=None, presets=None)[source]

Determine the tick locations

The first time this function is called it will try to set the number of ticks to make a nice tick partitioning. Thereafter the number of ticks will be fixed so that interactive navigation will be nice

Use presets to set locs based on lom. A dict mapping vmin, vmax->locs

property numticks
set_params(self, numticks=None, presets=None)[source]

Set parameters within this locator.

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

view_limits(self, vmin, vmax)[source]

Try to choose the view limits intelligently

class matplotlib.ticker.LogLocator(base=10.0, subs=(1.0, ), numdecs=4, numticks=None)[source]

Determine the tick locations for log axes

Place ticks on the locations : subs[j] * base**i

Parameters: subsNone, str, or sequence of float, optional, default (1.0,)Gives the multiples of integer powers of the base at which to place ticks. The default places ticks only at integer powers of the base. The permitted string values are 'auto' and 'all', both of which use an algorithm based on the axis view limits to determine whether and how to put ticks between integer powers of the base. With 'auto', ticks are placed only between integer powers; with 'all', the integer powers are included. A value of None is equivalent to 'auto'.
base(self, base)[source]

Set the log base (major tick every base**i, i integer).

nonsingular(self, vmin, vmax)[source]

Adjust a range as needed to avoid singularities.

This method gets called during autoscaling, with (v0, v1) set to the data limits on the axes if the axes contains any data, or (-inf, +inf) if not.

• If v0 == v1 (possibly up to some floating point slop), this method returns an expanded interval around this value.
• If (v0, v1) == (-inf, +inf), this method returns appropriate default view limits.
• Otherwise, (v0, v1) is returned without modification.
set_params(self, base=None, subs=None, numdecs=None, numticks=None)[source]

Set parameters within this locator.

subs(self, subs)[source]

Set the minor ticks for the log scaling every base**i*subs[j].

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

view_limits(self, vmin, vmax)[source]

Try to choose the view limits intelligently

class matplotlib.ticker.AutoLocator[source]

Dynamically find major tick positions. This is actually a subclass of MaxNLocator, with parameters nbins = 'auto' and steps = [1, 2, 2.5, 5, 10].

To know the values of the non-public parameters, please have a look to the defaults of MaxNLocator.

class matplotlib.ticker.MultipleLocator(base=1.0)[source]

Set a tick on each integer multiple of a base within the view interval.

set_params(self, base)[source]

Set parameters within this locator.

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

view_limits(self, dmin, dmax)[source]

Set the view limits to the nearest multiples of base that contain the data.

class matplotlib.ticker.MaxNLocator(*args, **kwargs)[source]

Select no more than N intervals at nice locations.

Parameters: nbinsint or 'auto', optional, default: 10Maximum number of intervals; one less than max number of ticks. If the string 'auto', the number of bins will be automatically determined based on the length of the axis. stepsarray-like, optionalSequence of nice numbers starting with 1 and ending with 10; e.g., [1, 2, 4, 5, 10], where the values are acceptable tick multiples. i.e. for the example, 20, 40, 60 would be an acceptable set of ticks, as would 0.4, 0.6, 0.8, because they are multiples of 2. However, 30, 60, 90 would not be allowed because 3 does not appear in the list of steps. integerbool, optional, default: FalseIf True, ticks will take only integer values, provided at least min_n_ticks integers are found within the view limits. symmetricbool, optional, default: FalseIf True, autoscaling will result in a range symmetric about zero. prune{'lower', 'upper', 'both', None}, optional, default: NoneRemove edge ticks -- useful for stacked or ganged plots where the upper tick of one axes overlaps with the lower tick of the axes above it, primarily when rcParams["axes.autolimit_mode"] (default: 'data') is 'round_numbers'. If prune=='lower', the smallest tick will be removed. If prune == 'upper', the largest tick will be removed. If prune == 'both', the largest and smallest ticks will be removed. If prune == None, no ticks will be removed. min_n_ticksint, optional, default: 2Relax nbins and integer constraints if necessary to obtain this minimum number of ticks.
default_params = {'integer': False, 'min_n_ticks': 2, 'nbins': 10, 'prune': None, 'steps': None, 'symmetric': False}
set_params(self, **kwargs)[source]

Set parameters for this locator.

Parameters: nbinsint or 'auto', optional stepsarray-like, optional integerbool, optional symmetricbool, optional prune{'lower', 'upper', 'both', None}, optional min_n_ticksint, optional
tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

view_limits(self, dmin, dmax)[source]

Select a scale for the range from vmin to vmax.

Subclasses should override this method to change locator behaviour.

class matplotlib.ticker.AutoMinorLocator(n=None)[source]

Dynamically find minor tick positions based on the positions of major ticks. The scale must be linear with major ticks evenly spaced.

n is the number of subdivisions of the interval between major ticks; e.g., n=2 will place a single minor tick midway between major ticks.

If n is omitted or None, it will be set to 5 or 4.

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

class matplotlib.ticker.SymmetricalLogLocator(transform=None, subs=None, linthresh=None, base=None)[source]

Determine the tick locations for symmetric log axes

Place ticks on the locations base**i*subs[j].

set_params(self, subs=None, numticks=None)[source]

Set parameters within this locator.

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

view_limits(self, vmin, vmax)[source]

Try to choose the view limits intelligently

class matplotlib.ticker.LogitLocator(minor=False, *, nbins='auto')[source]

Determine the tick locations for logit axes

Place ticks on the logit locations

Parameters: nbinsint or 'auto', optionalNumber of ticks. Only used if minor is False. minorbool, default: FalseIndicate if this locator is for minor ticks or not.
property minor
nonsingular(self, vmin, vmax)[source]

Adjust a range as needed to avoid singularities.

This method gets called during autoscaling, with (v0, v1) set to the data limits on the axes if the axes contains any data, or (-inf, +inf) if not.

• If v0 == v1 (possibly up to some floating point slop), this method returns an expanded interval around this value.
• If (v0, v1) == (-inf, +inf), this method returns appropriate default view limits.
• Otherwise, (v0, v1) is returned without modification.
set_params(self, minor=None, **kwargs)[source]

Set parameters within this locator.

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

class matplotlib.ticker.OldAutoLocator[source]

On autoscale this class picks the best MultipleLocator to set the view limits and the tick locs.

get_locator(self, d)[source]

Pick the best locator based on a distance d.

refresh(self)[source]

Refresh internal information based on current limits.

tick_values(self, vmin, vmax)[source]

Return the values of the located ticks given vmin and vmax.

Note

To get tick locations with the vmin and vmax values defined automatically for the associated axis simply call the Locator instance:

>>> print(type(loc))
<type 'Locator'>
>>> print(loc())
[1, 2, 3, 4]

view_limits(self, vmin, vmax)[source]

Try to choose the view limits intelligently