TexEngFormatter

class Stoner.plot.formats.TexEngFormatter(unit='', places=None, sep=' ', *, usetex=None, useMathText=None, useOffset=False)[source]

Bases: EngFormatter

An axis tick label formatter that emits Tex formula mode code.

Formatting is set so that large numbers are registered as with SI prefixes rather than using E notation.

Attributes Summary

ENG_PREFIXES

axis

locs

prefix

useLocale

Return whether locale settings are used for formatting.

useMathText

Return whether to use fancy math formatting.

useOffset

Return whether automatic mode for offset notation is active.

usetex

Return whether TeX's math mode is enabled for rendering.

Methods Summary

__call__(value[, pos])

Return the value ina suitable texable format.

create_dummy_axis(**kwargs)

fix_minus(s)

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 :rc:`axes.unicode_minus`.

format_data(value)

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

format_data_short(value)

Return a short string version of the tick value.

format_eng(num)

Alias to EngFormatter.format_data

format_ticks(values)

Return the tick labels for all the ticks at once.

get_offset()

Return scientific notation, plus offset.

get_useLocale()

Return whether locale settings are used for formatting.

get_useMathText()

Return whether to use fancy math formatting.

get_useOffset()

Return whether automatic mode for offset notation is active.

get_usetex()

Return whether TeX's math mode is enabled for rendering.

set_axis(axis)

set_locs(locs)

Set the locations of the ticks.

set_powerlimits(lims)

Set size thresholds for scientific notation.

set_scientific(b)

Turn scientific notation on or off.

set_useLocale(val)

Set whether to use locale settings for decimal sign and positive sign.

set_useMathText(val)

Set whether to use fancy math formatting.

set_useOffset(val)

Set whether to use offset notation.

set_usetex(val)

Set whether to use TeX's math mode for rendering numbers in the formatter.

Attributes Documentation

ENG_PREFIXES = {-30: 'q', -27: 'r', -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', 27: 'R', 30: 'Q'}
axis = None
locs = []
prefix = {-24: 'y', -21: 'z', -18: 'a', -15: 'f', -12: 'p', -9: 'n', -6: '\\mu', -3: 'm', 0: '', 3: 'k', 6: 'M', 9: 'G', 12: 'T', 15: 'P', 18: 'E', 21: 'Z', 24: 'Y'}
useLocale

Return whether locale settings are used for formatting.

See Also

ScalarFormatter.set_useLocale

useMathText

Return whether to use fancy math formatting.

See Also

ScalarFormatter.set_useMathText

useOffset

Return whether automatic mode for offset notation is active.

This returns True if set_useOffset(True); it returns False if an explicit offset was set, e.g. set_useOffset(1000).

See Also

ScalarFormatter.set_useOffset

usetex

Return whether TeX’s math mode is enabled for rendering.

Methods Documentation

__call__(value, pos=None)[source]

Return the value ina suitable texable format.

create_dummy_axis(**kwargs)
static fix_minus(s)

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 :rc:`axes.unicode_minus`.

format_data(value)[source]

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

format_data_short(value)[source]

Return a short string version of the tick value.

Defaults to the position-independent long value.

format_eng(num)

Alias to EngFormatter.format_data

format_ticks(values)

Return the tick labels for all the ticks at once.

get_offset()

Return scientific notation, plus offset.

get_useLocale()

Return whether locale settings are used for formatting.

See Also

ScalarFormatter.set_useLocale

get_useMathText()

Return whether to use fancy math formatting.

See Also

ScalarFormatter.set_useMathText

get_useOffset()

Return whether automatic mode for offset notation is active.

This returns True if set_useOffset(True); it returns False if an explicit offset was set, e.g. set_useOffset(1000).

See Also

ScalarFormatter.set_useOffset

get_usetex()

Return whether TeX’s math mode is enabled for rendering.

set_axis(axis)
set_locs(locs)

Set the locations of the ticks.

This method is called before computing the tick labels because some formatters need to know all tick locations to do so.

set_powerlimits(lims)

Set size thresholds for scientific notation.

Parameters

lims(int, int)

A tuple (min_exp, max_exp) containing the powers of 10 that determine the switchover threshold. For a number representable as \(a \times 10^\mathrm{exp}\) with \(1 <= |a| < 10\), scientific notation will be used if exp <= min_exp or exp >= max_exp.

The default limits are controlled by :rc:`axes.formatter.limits`.

In particular numbers with exp equal to the thresholds are written in scientific notation.

Typically, min_exp will be negative and max_exp will be positive.

For example, formatter.set_powerlimits((-3, 4)) will provide the following formatting: \(1 \times 10^{-3}, 9.9 \times 10^{-3}, 0.01,\) \(9999, 1 \times 10^4\).

See Also

ScalarFormatter.set_scientific

set_scientific(b)

Turn scientific notation on or off.

See Also

ScalarFormatter.set_powerlimits

set_useLocale(val)

Set whether to use locale settings for decimal sign and positive sign.

Parameters

valbool or None

None resets to :rc:`axes.formatter.use_locale`.

set_useMathText(val)

Set whether to use fancy math formatting.

If active, scientific notation is formatted as \(1.2 \times 10^3\).

Parameters

valbool or None

None resets to :rc:`axes.formatter.use_mathtext`.

set_useOffset(val)

Set whether to use offset notation.

When formatting a set numbers whose value is large compared to their range, the formatter can separate an additive constant. This can shorten the formatted numbers so that they are less likely to overlap when drawn on an axis.

Parameters

valbool or float
  • If False, do not use offset notation.

  • If True (=automatic mode), use offset notation if it can make the residual numbers significantly shorter. The exact behavior is controlled by :rc:`axes.formatter.offset_threshold`.

  • If a number, force an offset of the given value.

Examples

With active offset notation, the values

100_000, 100_002, 100_004, 100_006, 100_008

will be formatted as 0, 2, 4, 6, 8 plus an offset +1e5, which is written to the edge of the axis.

set_usetex(val)

Set whether to use TeX’s math mode for rendering numbers in the formatter.