FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: do not set constrained layout on false-y values by tacaswell · Pull Request #23987 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion lib/matplotlib/figure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2426,9 +2426,12 @@ def __init__(self,
if isinstance(tight_layout, dict):
self.get_layout_engine().set(**tight_layout)
elif constrained_layout is not None:
self.set_layout_engine(layout='constrained')
if isinstance(constrained_layout, dict):
self.set_layout_engine(layout='constrained')
self.get_layout_engine().set(**constrained_layout)
elif constrained_layout:
self.set_layout_engine(layout='constrained')

else:
# everything is None, so use default:
self.set_layout_engine(layout=layout)
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_constrainedlayout.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,14 @@ def test_compressed1():
pos = axs[1, 2].get_position()
np.testing.assert_allclose(pos.x1, 0.8618, atol=1e-3)
np.testing.assert_allclose(pos.y0, 0.1934, atol=1e-3)


@pytest.mark.parametrize('arg, state', [
(True, True),
(False, False),
({}, True),
({'rect': None}, True)
])
def test_set_constrained_layout(arg, state):
fig, ax = plt.subplots(constrained_layout=arg)
assert fig.get_constrained_layout() is state

Back | FazBrowse Home | New Git URL