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#

Make room for ylabel using axes_grid

Make room for ylabel using axes_grid

Parasite Simple

Parasite Simple

Ticklabel alignment

Ticklabel alignment

Simple axis tick label and tick directions

Simple axis tick label and tick directions

Simple Axisline

Simple Axisline

Color Demo

Color Demo

Keypress event

Keypress event

Contourf demo

Contourf demo

Spectrogram

Spectrogram

Tricontour Demo

Tricontour Demo

Tripcolor Demo

Tripcolor Demo

Triplot Demo

Triplot Demo

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

Plot 2D data on 3D plot

Plot 2D data on 3D plot

Create 2D bar graphs in different planes

Create 2D bar graphs in different planes

3D errorbars

3D errorbars

Lorenz attractor

Lorenz attractor

Automatic text offsetting

Automatic text offsetting

3D scatterplot

3D scatterplot

3D surface with polar coordinates

3D surface with polar coordinates

Text annotations in 3D

Text annotations in 3D

Asinh scale

Asinh scale

Line, Poly and RegularPoly Collection with autoscaling

Line, Poly and RegularPoly Collection with autoscaling

Ellipse Collection

Ellipse Collection

Anatomy of a figure

Anatomy of a figure

XKCD

XKCD

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

Dark background style sheet

Dark background style sheet

Align labels and titles

Align labels and titles

Axes Demo

Axes Demo

Axis label position

Axis label position

Resize Axes with constrained layout

Resize Axes with constrained layout

Resize Axes with tight layout

Resize Axes with tight layout

Figure labels: suptitle, supxlabel, supylabel

Figure labels: suptitle, supxlabel, supylabel

Inverted axis

Inverted axis

Secondary Axis

Secondary Axis

Figure subfigures

Figure subfigures

Multiple subplots

Multiple subplots

Plots with different scales

Plots with different scales

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

Center labels between ticks

Center labels between ticks

Slider

Slider

Artist tutorial

Artist tutorial

Arranging multiple Axes in a Figure

Arranging multiple Axes in a Figure

Axis scales

Axis scales

Plotting dates and strings

Plotting dates and strings

Constrained layout guide

Constrained layout guide

Tight layout guide

Tight layout guide

Choosing Colormaps in Matplotlib

Choosing Colormaps in Matplotlib

Quick start guide

Quick start guide

Text in Matplotlib

Text in Matplotlib