Skip to content

Commit 203af57

Browse files
timhoffmmeeseeksmachine
authored andcommitted
Backport PR matplotlib#31649: DOC: Prevent ticks from being cut off in tick rotation example
1 parent ef8e524 commit 203af57

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)