TexFormatter

class stonerplots.TexFormatter

Bases: Formatter

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

Formatting is set so that large numbers are registered as \(\times 10^{power}\) rather than using E notation.

Examples:
>>> import matplotlib.pyplot as plt
>>> from stonerplots.format import TexFormatter
>>> fig, ax = plt.subplots()
>>> ax.yaxis.set_major_formatter(TexFormatter())
>>> ax.plot([0, 1e6, 2e6], [0, 1, 2])
>>> plt.show()

Methods Summary

__call__(value[, pos])

Return the value in a suitable texable format.

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.

Methods Documentation

__call__(value: float, pos: int | None = None) str

Return the value in a suitable texable format.

format_data(value: float) str

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

format_data_short(value: float | MaskedArray) str

Return a short string version of the tick value.

Defaults to the position-independent long value.