diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index e68427e0c159..2155e5422af9 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -286,6 +286,13 @@ def __init__(self, parent, handles, labels, ncol = 1 self._ncol = ncol + if ( + not isinstance(self.numpoints, int) and + not isinstance(self.numpoints, float) and + not self.numpoints.is_integer() + ): + raise ValueError("numpoints must be a whole number; it was %f" + % numpoints) if self.numpoints <= 0: raise ValueError("numpoints must be > 0; it was %d" % numpoints)