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#

Creating a timeline with lines, dates, and text

Creating a timeline with lines, dates, and text

Creating a timeline with lines, dates, and text
Date tick labels

Date tick labels

Date tick labels
Labeling ticks using engineering notation

Labeling ticks using engineering notation

Labeling ticks using engineering notation
Dollar Ticks

Dollar Ticks

Dollar Ticks
3D surface (colormap)

3D surface (colormap)

3D surface (colormap)
SkewT-logP diagram: using transforms and custom projections

SkewT-logP diagram: using transforms and custom projections

SkewT-logP diagram: using transforms and custom projections
Centering labels between ticks

Centering labels between ticks

Centering labels between ticks
Custom Ticker

Custom Ticker

Custom Ticker
Formatting date ticks using ConciseDateFormatter

Formatting date ticks using ConciseDateFormatter

Formatting date ticks using ConciseDateFormatter
Date Demo Convert

Date Demo Convert

Date Demo Convert
Placing date ticks using recurrence rules

Placing date ticks using recurrence rules

Placing date ticks using recurrence rules
Custom tick formatter for time series

Custom tick formatter for time series

Custom tick formatter for time series
Major and minor ticks

Major and minor ticks

Major and minor ticks
Setting tick labels from a list of values

Setting tick labels from a list of values

Setting tick labels from a list of values
The Lifecycle of a Plot

The Lifecycle of a Plot

The Lifecycle of a Plot
Quick start guide

Quick start guide

Quick start guide
Artist tutorial

Artist tutorial

Artist tutorial
Choosing Colormaps in Matplotlib

Choosing Colormaps in Matplotlib

Choosing Colormaps in Matplotlib
Text in Matplotlib Plots

Text in Matplotlib Plots

Text in Matplotlib Plots