diff --git a/lib/matplotlib/units.py b/lib/matplotlib/units.py index bcc40f460656..24df5a350c6d 100644 --- a/lib/matplotlib/units.py +++ b/lib/matplotlib/units.py @@ -149,7 +149,13 @@ def get_converter(self, x): return converter except AttributeError: # not a masked_array - converter = self.get_converter(xravel[0]) + # Make sure we don't recurse forever -- it's possible for + # ndarray subclasses to continue to return subclasses and + # not ever return a non-subclass for a single element. + next_item = xravel[0] + if (not isinstance(next_item, np.ndarray) or + next_item.shape != x.shape): + converter = self.get_converter(next_item) return converter if converter is None and iterable(x):