|
20 | 20 | """
|
21 | 21 |
|
22 | 22 | import matplotlib.pyplot as plt
|
23 |
| -import numpy as np |
24 | 23 |
|
25 | 24 |
|
26 |
| -def test_rotation_mode(fig, mode, subplot_location): |
| 25 | +def test_rotation_mode(fig, mode): |
27 | 26 | ha_list = ["left", "center", "right"]
|
28 | 27 | va_list = ["top", "center", "baseline", "bottom"]
|
29 |
| - axs = np.empty((len(va_list), len(ha_list)), object) |
30 |
| - gs = subplot_location.subgridspec(*axs.shape, hspace=0, wspace=0) |
31 |
| - axs[0, 0] = fig.add_subplot(gs[0, 0]) |
32 |
| - for i in range(len(va_list)): |
33 |
| - for j in range(len(ha_list)): |
34 |
| - if (i, j) == (0, 0): |
35 |
| - continue # Already set. |
36 |
| - axs[i, j] = fig.add_subplot( |
37 |
| - gs[i, j], sharex=axs[0, 0], sharey=axs[0, 0]) |
38 |
| - for ax in axs.flat: |
39 |
| - ax.set(aspect=1) |
| 28 | + axs = fig.subplots(len(va_list), len(ha_list), sharex=True, sharey=True, |
| 29 | + subplot_kw=dict(aspect=1), |
| 30 | + gridspec_kw=dict(hspace=0, wspace=0)) |
40 | 31 |
|
41 | 32 | # labels and title
|
42 | 33 | for ha, ax in zip(ha_list, axs[-1, :]):
|
@@ -79,9 +70,9 @@ def test_rotation_mode(fig, mode, subplot_location):
|
79 | 70 |
|
80 | 71 |
|
81 | 72 | fig = plt.figure(figsize=(8, 5))
|
82 |
| -gs = fig.add_gridspec(1, 2) |
83 |
| -test_rotation_mode(fig, "default", gs[0]) |
84 |
| -test_rotation_mode(fig, "anchor", gs[1]) |
| 73 | +subfigs = fig.subfigures(1, 2) |
| 74 | +test_rotation_mode(subfigs[0], "default") |
| 75 | +test_rotation_mode(subfigs[1], "anchor") |
85 | 76 | plt.show()
|
86 | 77 |
|
87 | 78 |
|
|
0 commit comments