From 61300dd1da3fcfac8cdd6eca3427b11f95605710 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 31 Jan 2014 22:36:30 -0500 Subject: [PATCH] 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 --- lib/matplotlib/figure.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index a485fdefc584..34f529ecb044 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -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):