Skip to content

Commit c542bf0

Browse files
authored
Merge pull request matplotlib#31651 from meeseeksmachine/auto-backport-of-pr-31649-on-v3.11.x
Backport PR matplotlib#31649 on branch v3.11.x (DOC: Prevent ticks from being cut off in tick rotation example)
2 parents 3b9f185 + 203af57 commit c542bf0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

galleries/examples/ticks/ticklabels_rotation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
Adjust the tick properties using `~.Axes.tick_params`: Set the angle in degrees via
88
the *rotation* parameter. Set the *rotation_mode* parameter to "xtick" / "ytick" to
99
make the text point towards the tick, see also `~.Text.set_rotation_mode`.
10+
11+
Note: We use ``layout="constrained"`` to make sure there is enough space for the tick
12+
labels so that they are not cut off.
1013
"""
1114

1215
import matplotlib.pyplot as plt
@@ -30,7 +33,7 @@
3033
'Vietnam': 102.3,
3134
}
3235

33-
fig, ax = plt.subplots()
36+
fig, ax = plt.subplots(layout="constrained")
3437
ax.bar(population.keys(), population.values())
3538
ax.tick_params("x", rotation=45, rotation_mode="xtick")
3639
ax.set_ylabel("population (millions)")

0 commit comments

Comments
 (0)