Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84008ea

Browse files
authored
Merge pull request #10393 from afvincent/ooify_examples_from_10306
OOification of the new examples from #10306
2 parents 0ec4633 + fef08f1 commit 84008ea

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

examples/ticks_and_spines/tick_label_right.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,20 @@
99
These properties can also be set in the ``.matplotlib/matplotlibrc``.
1010
1111
"""
12-
13-
1412
import matplotlib.pyplot as plt
1513
import numpy as np
1614

1715
plt.rcParams['ytick.right'] = plt.rcParams['ytick.labelright'] = True
1816
plt.rcParams['ytick.left'] = plt.rcParams['ytick.labelleft'] = False
1917

20-
2118
x = np.arange(10)
2219

23-
_, ax = plt.subplots(2, 1, sharex=True, figsize=(6, 6))
20+
fig, (ax0, ax1) = plt.subplots(2, 1, sharex=True, figsize=(6, 6))
2421

25-
ax[0].plot(x)
26-
ax[0].yaxis.tick_left()
22+
ax0.plot(x)
23+
ax0.yaxis.tick_left()
2724

2825
# use default parameter in rcParams, not calling tick_right()
29-
ax[1].plot(x)
26+
ax1.plot(x)
3027

3128
plt.show()

examples/ticks_and_spines/tick_xlabel_top.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
These properties can also be set in the ``.matplotlib/matplotlibrc``.
1111
1212
"""
13-
14-
1513
import matplotlib.pyplot as plt
1614
import numpy as np
1715

@@ -21,6 +19,9 @@
2119

2220
x = np.arange(10)
2321

24-
plt.plot(x)
25-
plt.title('xlabel top')
22+
fig, ax = plt.subplots()
23+
24+
ax.plot(x)
25+
ax.set_title('xlabel top', pad=24) # increase padding to make room for labels
26+
2627
plt.show()

0 commit comments

Comments
 (0)