Signature
Axes.set(xlabel=None, ylabel=None, title=None, xlim=None, ylim=None)What it does
Axes.set groups several familiar setters into one method. It is a compact way to label a chart and control the visible range without repeating ax.set_xlabel, ax.set_ylabel, and ax.set_title.
Parameters
xlabelstr, optionaloptional- Label for the horizontal axis.
ylabelstr, optionaloptional- Label for the vertical axis.
titlestr, optionaloptional- Title shown above the axes.
xlim, ylimtuple, optionaloptional- Lower and upper limits for each axis.
Returns
None
Example
pythonAxes.set example
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([0, 1, 2, 3], [1, 4, 2, 5])
ax.set(
title="Reading over time",
xlabel="minute",
ylabel="value",
ylim=(0, 6),
)Watch out for
- Only the arguments you pass are changed; the others keep their current values.
- Limits are data coordinates, not pixel sizes.