Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2348faa

Browse files
authored
Merge pull request #17610 from tacaswell/enh_zero_size_figure
MNT: allow 0 sized figures
2 parents 21c3acb + 4b3301f commit 2348faa

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/matplotlib/figure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def __init__(self,
317317
if frameon is None:
318318
frameon = mpl.rcParams['figure.frameon']
319319

320-
if not np.isfinite(figsize).all() or (np.array(figsize) <= 0).any():
320+
if not np.isfinite(figsize).all() or (np.array(figsize) < 0).any():
321321
raise ValueError('figure size must be positive finite not '
322322
f'{figsize}')
323323
self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
@@ -876,7 +876,7 @@ def set_size_inches(self, w, h=None, forward=True):
876876
if h is None: # Got called with a single pair as argument.
877877
w, h = w
878878
size = np.array([w, h])
879-
if not np.isfinite(size).all() or (size <= 0).any():
879+
if not np.isfinite(size).all() or (size < 0).any():
880880
raise ValueError(f'figure size must be positive finite not {size}')
881881
self.bbox_inches.p1 = size
882882
if forward:

lib/matplotlib/tests/test_figure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ def test_change_dpi():
374374

375375
@pytest.mark.parametrize('width, height', [
376376
(1, np.nan),
377-
(0, 1),
378377
(-1, 1),
379378
(np.inf, 1)
380379
])

0 commit comments

Comments
 (0)