Skip to content

Commit 61300dd

Browse files
committed
ENH : improve error invalid error message for subplot
Closes #2098 If user passes in a not-three-digit integer, raise `ValueError` instead of letting the error propagate up from much farther down the stack
1 parent 9a164c7 commit 61300dd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/matplotlib/figure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,10 @@ def add_subplot(self, *args, **kwargs):
901901

902902
if len(args) == 1 and isinstance(args[0], int):
903903
args = tuple([int(c) for c in str(args[0])])
904+
if len(args) != 3:
905+
raise ValueError("Integer subplot specification must " +
906+
"be a three digit number. " +
907+
"Not {n:d}".format(n=len(args)))
904908

905909
if isinstance(args[0], SubplotBase):
906910

0 commit comments

Comments
 (0)