Skip to content

Commit

Permalink
ENH : improve error invalid error message for subplot
Browse files Browse the repository at this point in the history
Closes matplotlib#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
  • Loading branch information
tacaswell committed Feb 2, 2014
1 parent 9a164c7 commit 61300dd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/matplotlib/figure.py
Expand Up @@ -901,6 +901,10 @@ def add_subplot(self, *args, **kwargs):

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

if isinstance(args[0], SubplotBase):

Expand Down

0 comments on commit 61300dd

Please sign in to comment.