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

Skip to content

Commit bc9396c

Browse files
committed
Check for positive number or rows and cols
1 parent f58c933 commit bc9396c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/axes/_subplots.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def __init__(self, fig, *args, **kwargs):
4848
rows, cols, num = args
4949
rows = int(rows)
5050
cols = int(cols)
51+
if rows <= 0:
52+
raise ValueError(f'Number of rows must be > 0, not {rows}')
53+
if cols <= 0:
54+
raise ValueError(f'Number of columns must be > 0, not {cols}')
5155
if isinstance(num, tuple) and len(num) == 2:
5256
num = [int(n) for n in num]
5357
self._subplotspec = GridSpec(

0 commit comments

Comments
 (0)