Skip to content

Commit 3b9b1a2

Browse files
authored
Merge pull request matplotlib#28013 from anntzer/uxt
Avoid plt.xticks/plt.yticks in gallery examples.
2 parents 1b36177 + 92f8978 commit 3b9b1a2

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

galleries/examples/subplots_axes_and_figures/secondary_axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def inverse(x):
154154

155155
ax.plot(dates, temperature)
156156
ax.set_ylabel(r'$T\ [^oC]$')
157-
plt.xticks(rotation=70)
157+
ax.xaxis.set_tick_params(rotation=70)
158158

159159

160160
def date2yday(x):

galleries/examples/ticks/ticklabels_rotation.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@
55
66
Demo of custom tick-labels with user-defined rotation.
77
"""
8+
89
import matplotlib.pyplot as plt
910

1011
x = [1, 2, 3, 4]
1112
y = [1, 4, 9, 6]
1213
labels = ['Frogs', 'Hogs', 'Bogs', 'Slogs']
1314

14-
plt.plot(x, y)
15+
fig, ax = plt.subplots()
16+
ax.plot(x, y)
1517
# You can specify a rotation for the tick labels in degrees or with keywords.
16-
plt.xticks(x, labels, rotation='vertical')
17-
# Pad margins so that markers don't get clipped by the Axes
18-
plt.margins(0.2)
19-
# Tweak spacing to prevent clipping of tick-labels
20-
plt.subplots_adjust(bottom=0.15)
18+
ax.set_xticks(x, labels, rotation='vertical')
19+
2120
plt.show()

0 commit comments

Comments
 (0)