Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 698cf7f

Browse filesBrowse files
committed
TST: add better test for uneven layout
1 parent 5974a56 commit 698cf7f
Copy full SHA for 698cf7f

File tree

Expand file treeCollapse file tree

3 files changed

+24
-6
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+24
-6
lines changed

‎lib/matplotlib/_constrained_layout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_constrained_layout.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,18 +394,18 @@ def do_constrained_layout(fig, renderer, h_pad, w_pad,
394394
if height0 > heightC:
395395
if in_same_column(ss0, ssc):
396396
ax._poslayoutbox.constrain_height_min(
397-
axc._poslayoutbox.height * height0 /
398-
heightC)
397+
axc._poslayoutbox.height * height0 / heightC)
398+
# these constraints stop the smaller axes from
399+
# being allowed to go to zero height...
399400
axc._poslayoutbox.constrain_height_min(
400-
ax._poslayoutbox.height * heightC /
401+
ax._poslayoutbox.height * heightC /
401402
(height0*1.8))
402403
else:
403404
if in_same_column(ss0, ssc):
404405
axc._poslayoutbox.constrain_height_min(
405-
ax._poslayoutbox.height * heightC /
406-
(height0))
406+
ax._poslayoutbox.height * heightC / height0)
407407
ax._poslayoutbox.constrain_height_min(
408-
ax._poslayoutbox.height * height0 /
408+
ax._poslayoutbox.height * height0 /
409409
(heightC*1.8))
410410
if drows0 == drowsC:
411411
ax._poslayoutbox.constrain_height(
Loading

‎lib/matplotlib/tests/test_constrainedlayout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_constrainedlayout.py
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,21 @@ def test_constrained_layout16():
345345
fig, ax = plt.subplots(constrained_layout=True)
346346
example_plot(ax, fontsize=12)
347347
ax2 = fig.add_axes([0.2, 0.2, 0.4, 0.4])
348+
349+
350+
@image_comparison(baseline_images=['constrained_layout17'],
351+
extensions=['png'])
352+
def test_constrained_layout17():
353+
'Test uneven gridspecs'
354+
fig = plt.figure(constrained_layout=True)
355+
gs = gridspec.GridSpec(3, 3, figure=fig)
356+
357+
ax1 = fig.add_subplot(gs[0, 0])
358+
ax2 = fig.add_subplot(gs[0, 1:])
359+
ax3 = fig.add_subplot(gs[1:, 0:2])
360+
ax4 = fig.add_subplot(gs[1:, -1])
361+
362+
example_plot(ax1)
363+
example_plot(ax2)
364+
example_plot(ax3)
365+
example_plot(ax4)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.