PintConverter

class metpy.units.PintConverter[source]

Implement support for pint within matplotlib’s unit conversion framework.

Methods Summary

axisinfo(unit, axis) return an units.AxisInfo instance for axis with the specified units
convert(value, unit, axis) Convert pint :Quantity instances for matplotlib to use.
default_units(x, axis) return the default unit for x or None for the given axis
is_numlike(x) The matplotlib datalim, autoscaling, locators etc work with scalars which are the units converted to floats given the current unit.

Methods Documentation

axisinfo(unit, axis)

return an units.AxisInfo instance for axis with the specified units

static convert(value, unit, axis)[source]

Convert pint :Quantity instances for matplotlib to use.

Currently only strips off the units to avoid matplotlib errors since we can’t reliably have pint.Quantity instances not decay to numpy arrays.

default_units(x, axis)

return the default unit for x or None for the given axis

is_numlike(x)

The matplotlib datalim, autoscaling, locators etc work with scalars which are the units converted to floats given the current unit. The converter may be passed these floats, or arrays of them, even when units are set. Derived conversion interfaces may opt to pass plain-ol unitless numbers through the conversion interface and this is a helper function for them.