Skip to content

MNT: allow 0 sized figures #17610

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 1 commit into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def __init__(self,
if frameon is None:
frameon = mpl.rcParams['figure.frameon']

if not np.isfinite(figsize).all() or (np.array(figsize) <= 0).any():
if not np.isfinite(figsize).all() or (np.array(figsize) < 0).any():
raise ValueError('figure size must be positive finite not '
f'{figsize}')
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
Expand Down Expand Up @@ -876,7 +876,7 @@ def set_size_inches(self, w, h=None, forward=True):
if h is None: # Got called with a single pair as argument.
w, h = w
size = np.array([w, h])
if not np.isfinite(size).all() or (size <= 0).any():
if not np.isfinite(size).all() or (size < 0).any():
raise ValueError(f'figure size must be positive finite not {size}')
self.bbox_inches.p1 = size
if forward:
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ def test_change_dpi():

@pytest.mark.parametrize('width, height', [
(1, np.nan),
(0, 1),
(-1, 1),
(np.inf, 1)
])
Expand Down