matplotlib.axes.Axes.set_xlabel#

Axes.set_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"] (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"] (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.

Examples using matplotlib.axes.Axes.set_xlabel#

Bar chart with labels

Bar chart with labels

Horizontal bar chart

Horizontal bar chart

Cross spectral density (CSD)

Cross spectral density (CSD)

fill_between with transparency

fill_between with transparency

Fill the area between two lines

Fill the area between two lines

Fill the area between two vertical lines

Fill the area between two vertical lines

Hat graph

Hat graph

Mapping marker properties to multivariate data

Mapping marker properties to multivariate data

Power spectral density (PSD)

Power spectral density (PSD)

Scatter Demo2

Scatter Demo2

Stackplots and streamgraphs

Stackplots and streamgraphs

hlines and vlines

hlines and vlines

Contourf demo

Contourf demo

Spectrogram

Spectrogram

Tricontour Demo

Tricontour Demo

Tripcolor Demo

Tripcolor Demo

Triplot Demo

Triplot Demo

Boxplots

Boxplots

Box plot vs. violin plot comparison

Box plot vs. violin plot comparison

Violin plot customization

Violin plot customization

Cumulative distributions

Cumulative distributions

Histogram bins, density, and weight

Histogram bins, density, and weight

Multiple histograms side by side

Multiple histograms side by side

Accented text

Accented text

Format ticks using engineering notation

Format ticks using engineering notation

Using ttf font files

Using ttf font files

Legend Demo

Legend Demo

Mathtext

Mathtext

Multiline

Multiline

Render math equations using TeX

Render math equations using TeX

Text properties

Text properties

Title positioning

Title positioning

Color Demo

Color Demo

Line, Poly and RegularPoly Collection with autoscaling

Line, Poly and RegularPoly Collection with autoscaling

Ellipse Collection

Ellipse Collection

Dark background style sheet

Dark background style sheet

Ticklabel alignment

Ticklabel alignment

Simple axis tick label and tick directions

Simple axis tick label and tick directions

Simple Axisline

Simple Axisline

Anatomy of a figure

Anatomy of a figure

XKCD

XKCD

Keypress event

Keypress event

Asinh scale

Asinh scale

Center labels between ticks

Center labels between ticks

Slider

Slider

Artist tutorial

Artist tutorial

Quick start guide

Quick start guide

Choosing Colormaps in Matplotlib

Choosing Colormaps in Matplotlib

Text in Matplotlib

Text in Matplotlib