matplotlib.pyplot.xlabel — Matplotlib 3.10.1 documentation (original) (raw)

matplotlib.pyplot.xlabel(xlabel, fontdict=None, labelpad=None, *, loc=None, **kwargs)[source]#

Set the label for the x-axis.

Parameters:

xlabelstr

The label text.

labelpadfloat, default: [rcParams["axes.labelpad"]](../../users/explain/customizing.html?highlight=axes.labelpad#matplotlibrc-sample) (default: 4.0)

Spacing in points from the Axes bounding box including ticks and tick labels. If None, the previous value is left as is.

loc{'left', 'center', 'right'}, default: [rcParams["xaxis.labellocation"]](../../users/explain/customizing.html?highlight=xaxis.labellocation#matplotlibrc-sample) (default: 'center')

The label position. This is a high-level alternative for passing parameters x and horizontalalignment.

Other Parameters:

**kwargsText properties

Text properties control the appearance of the label.

See also

text

Documents the properties supported by Text.

Notes

Examples using matplotlib.pyplot.xlabel#