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 Label Demo

Bar Label Demo

Horizontal bar chart

Horizontal bar chart

Broken Barh

Broken Barh

Cross spectral density (CSD)

Cross spectral density (CSD)

Fill Between and Alpha

Fill Between and Alpha

Filling the area between lines

Filling the area between lines

Fill Betweenx Demo

Fill Betweenx Demo

Hatch-filled histograms

Hatch-filled histograms

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

Aligning Labels

Aligning Labels

Axes Demo

Axes Demo

Axis Label Position

Axis Label Position

Resizing axes with constrained layout

Resizing axes with constrained layout

Resizing axes with tight layout

Resizing axes with tight layout

Figure labels: suptitle, supxlabel, supylabel

Figure labels: suptitle, supxlabel, supylabel

Invert Axes

Invert Axes

Secondary Axis

Secondary Axis

Figure subfigures

Figure subfigures

Multiple subplots

Multiple subplots

Plots with different scales

Plots with different scales

Box plots with custom fill colors

Box plots with custom fill colors

Boxplots

Boxplots

Box plot vs. violin plot comparison

Box plot vs. violin plot comparison

Violin plot customization

Violin plot customization

Plotting cumulative distributions

Plotting cumulative distributions

Some features of the histogram (hist) function

Some features of the histogram (hist) function

Producing multiple histograms side by side

Producing multiple histograms side by side

Accented text

Accented text

Labeling ticks using engineering notation

Labeling ticks using engineering notation

Using ttf font files

Using ttf font files

Legend Demo

Legend Demo

Mathtext

Mathtext

Multiline

Multiline

Rendering math equations using TeX

Rendering math equations using TeX

Text Commands

Text Commands

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

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

Anatomy of a figure

Anatomy of a figure

XKCD

XKCD

Keypress event

Keypress event

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 Demo

Asinh Demo

Log Bar

Log Bar

Centering labels between ticks

Centering labels between ticks

Slider

Slider

PGF fonts

PGF fonts

PGF texsystem

PGF texsystem

Artist tutorial

Artist tutorial

Quick start guide

Quick start guide

Constrained layout guide

Constrained layout guide

Tight layout guide

Tight layout guide

Arranging multiple Axes in a Figure

Arranging multiple Axes in a Figure

Axis scales

Axis scales

Choosing Colormaps in Matplotlib

Choosing Colormaps in Matplotlib

Text in Matplotlib

Text in Matplotlib