diff options
| author | andrewgsavage <andrewgsavage@gmail.com> | 2019-06-29 11:32:50 +0100 |
|---|---|---|
| committer | andrewgsavage <andrewgsavage@gmail.com> | 2019-06-29 11:32:50 +0100 |
| commit | 6c880bb8360a3792e0f163c9e2f2f6b2f427c866 (patch) | |
| tree | 54e5d6e83bd2372f6c3a812b7da6e715e5f560d0 /pint/matplotlib.py | |
| parent | b5127a2dbbbcde9241aeb717612c8516e7c54186 (diff) | |
| download | pint-6c880bb8360a3792e0f163c9e2f2f6b2f427c866.tar.gz | |
allow np arrays of scalar quantities to be plotted
Diffstat (limited to 'pint/matplotlib.py')
| -rw-r--r-- | pint/matplotlib.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pint/matplotlib.py b/pint/matplotlib.py index bda251d..0d28d43 100644 --- a/pint/matplotlib.py +++ b/pint/matplotlib.py @@ -31,7 +31,7 @@ class PintConverter(matplotlib.units.ConversionInterface): def convert(self, value, unit, axis): """Convert :`Quantity` instances for matplotlib to use.""" - if isinstance(value, (tuple, list)): + if hasattr(value,"__iter__"): return [self._convert_value(v, unit, axis) for v in value] else: return self._convert_value(value, unit, axis) @@ -51,6 +51,8 @@ class PintConverter(matplotlib.units.ConversionInterface): @staticmethod def default_units(x, axis): """Get the default unit to use for the given combination of unit and axis.""" + if hasattr(x,"__iter__") and len(x) > 0: + return getattr(x[0], 'units', None) return getattr(x, 'units', None) |
