matplotlib.axis.Axis.set_major_formatter#

Axis.set_major_formatter(formatter)[source]#

Set the formatter of the major ticker.

In addition to a Formatter instance, this also accepts a str or function.

For a str a StrMethodFormatter is used. The field used for the value must be labeled 'x' and the field used for the position must be labeled 'pos'. See the StrMethodFormatter documentation for more information.

For a function, a FuncFormatter is used. The function must take two inputs (a tick value x and a position pos), and return a string containing the corresponding tick label. See the FuncFormatter documentation for more information.

Parameters:
formatterFormatter, str, or function

Examples using matplotlib.axis.Axis.set_major_formatter#

Timeline with lines, dates, and text

Timeline with lines, dates, and text

Major and minor ticks

Major and minor ticks

Center labels between ticks

Center labels between ticks

Multilevel (nested) ticks

Multilevel (nested) ticks

Tick formatters

Tick formatters

Custom Ticker

Custom Ticker

Dollar ticks

Dollar ticks

Format ticks using engineering notation

Format ticks using engineering notation

SI prefixed offsets and natural order of magnitudes

SI prefixed offsets and natural order of magnitudes

Setting tick labels from a list of values

Setting tick labels from a list of values

Date tick labels

Date tick labels

Date tick locators and formatters

Date tick locators and formatters

Format date ticks using ConciseDateFormatter

Format date ticks using ConciseDateFormatter

Date converter demo

Date converter demo

Placing date ticks using recurrence rules

Placing date ticks using recurrence rules

Custom tick formatter for time series

Custom tick formatter for time series

3D surface (colormap)

3D surface (colormap)

SkewT-logP diagram: using transforms and custom projections

SkewT-logP diagram: using transforms and custom projections

The Lifecycle of a Plot

The Lifecycle of a Plot

Quick start guide

Quick start guide

Axis ticks

Axis ticks

Plotting dates and strings

Plotting dates and strings

Choosing Colormaps in Matplotlib

Choosing Colormaps in Matplotlib

Text in Matplotlib

Text in Matplotlib