Skip to content

FIX/TST constrained_layout remove test8 duplication #10725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 14 additions & 54 deletions lib/matplotlib/tests/test_constrainedlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,6 @@ def test_constrained_layout6():
ticks=ticker.MaxNLocator(nbins=5))


@image_comparison(baseline_images=['constrained_layout8'],
extensions=['png'])
def test_constrained_layout8():
'Test for gridspecs that are not completely full'
fig = plt.figure(figsize=(7, 4), constrained_layout=True)
gs = gridspec.GridSpec(3, 5, figure=fig)
axs = []
j = 1
for i in [0, 1]:
ax = fig.add_subplot(gs[j, i])
axs += [ax]
pcm = example_pcolor(ax, fontsize=10)
if i > 0:
ax.set_ylabel('')
if j < 1:
ax.set_xlabel('')
ax.set_title('')
j = 0
for i in [2, 4]:
ax = fig.add_subplot(gs[j, i])
axs += [ax]
pcm = example_pcolor(ax, fontsize=10)
if i > 0:
ax.set_ylabel('')
if j < 1:
ax.set_xlabel('')
ax.set_title('')
ax = fig.add_subplot(gs[2, :])
axs += [ax]
pcm = example_pcolor(ax, fontsize=10)

fig.colorbar(pcm, ax=axs, pad=0.01, shrink=0.6)


def test_constrained_layout7():
'Test for proper warning if fig not set in GridSpec'
with pytest.warns(UserWarning, match='Calling figure.constrained_layout, '
Expand All @@ -179,26 +145,20 @@ def test_constrained_layout8():
fig = plt.figure(figsize=(10, 5), constrained_layout=True)
gs = gridspec.GridSpec(3, 5, figure=fig)
axs = []
j = 1
for i in [0, 4]:
ax = fig.add_subplot(gs[j, i])
axs += [ax]
pcm = example_pcolor(ax, fontsize=9)
if i > 0:
ax.set_ylabel('')
if j < 1:
ax.set_xlabel('')
ax.set_title('')
j = 0
for i in [1]:
ax = fig.add_subplot(gs[j, i])
axs += [ax]
pcm = example_pcolor(ax, fontsize=9)
if i > 0:
ax.set_ylabel('')
if j < 1:
ax.set_xlabel('')
ax.set_title('')
for j in [0, 1]:
if j == 0:
ilist = [1]
else:
ilist = [0, 4]
for i in ilist:
ax = fig.add_subplot(gs[j, i])
axs += [ax]
pcm = example_pcolor(ax, fontsize=9)
if i > 0:
ax.set_ylabel('')
if j < 1:
ax.set_xlabel('')
ax.set_title('')
ax = fig.add_subplot(gs[2, :])
axs += [ax]
pcm = example_pcolor(ax, fontsize=9)
Expand Down