10000 Merge pull request #18554 from timhoffm/test-subplots2 · matplotlib/matplotlib@ef1f8c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef1f8c9

Browse files
authored
Merge pull request #18554 from timhoffm/test-subplots2
TST: Replace some usages of plt.subplot() by plt.subplots() in tests
2 parents 371b9ab + 3907771 commit ef1f8c9

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

lib/matplotlib/tests/test_artist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ def test_clipping():
105105
star = mpath.Path.unit_regular_star(6).deepcopy()
106106
star.vertices *= 2.6
107107

108-
ax1 = plt.subplot(121)
108+
fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True, sharey=True)
109+
109110
col = mcollections.PathCollection([star], lw=5, edgecolor='blue',
110111 8000
facecolor='red', alpha=0.7, hatch='*')
111112
col.set_clip_path(clip_path, ax1.transData)
112113
ax1.add_collection(col)
113114

114-
ax2 = plt.subplot(122, sharex=ax1, sharey=ax1)
115115
patch = mpatches.PathPatch(star, lw=5, edgecolor='blue', facecolor='red',
116116
alpha=0.7, hatch='*')
117117
patch.set_clip_path(clip_path, ax2.transData)

lib/matplotlib/tests/test_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5467,12 +5467,12 @@ def test_shared_axes_autoscale():
54675467
l = np.arange(-80, 90, 40)
54685468
t = np.random.random_sample((l.size, l.size))
54695469

5470-
ax1 = plt.subplot(211)
5470+
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True, sharey=True)
5471+
54715472
ax1.set_xlim(-1000, 1000)
54725473
ax1.set_ylim(-1000, 1000)
54735474
ax1.co 8000 ntour(l, l, t)
54745475

5475-
ax2 = plt.subplot(212, sharex=ax1, sharey=ax1)
54765476
ax2.contour(l, l, t)
54775477
assert not ax1.get_autoscalex_on() and not ax2.get_autoscalex_on()
54785478
assert not ax1.get_autoscaley_on() and not ax2.get_autoscaley_on()

lib/matplotlib/tests/test_image.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,13 @@ def test_imsave_pil_kwargs_tiff():
260260

261261
@image_comparison(['image_alpha'], remove_text=True)
262262
def test_image_alpha():
263-
plt.figure()
264-
265263
np.random.seed(0)
266264
Z = np.random.rand(6, 6)
267265

268-
plt.subplot(131)
269-
plt.imshow(Z, alpha=1.0, interpolation='none')
270-
271-
plt.subplot(132)
272-
plt.imshow(Z, alpha=0.5, interpolation='none')
273-
274-
plt.subplot(133)
275-
plt.imshow(Z, alpha=0.5, interpolation='nearest')
266+
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)
267+
ax1.imshow(Z, alpha=1.0, interpolation='none')
268+
ax2.imshow(Z, alpha=0.5, interpolation='none')
269+
ax3.imshow(Z, alpha=0.5, interpolation='nearest')
276270

277271

278272
def test_cursor_data():

0 commit comments

Comments
 (0)
0