Skip to main content
`Ctrl`+`K`

# MplQuantityConverter

class astropy.visualization.MplQuantityConverter

  Bases: `ConversionInterface`, `ContextDecorator`

  Matplotlib converter for `astropy.units.Quantity`.

  Registers itself to matplotlib as the converter for `astropy.units.Quantity` when initialized. If used as a context manager, it will restore the original converter upon exit. Also see `quantity_support()` for a convenient way to use this converter with an optional format for the `axisinfo`.

  Methods Summary

  `__call__`(func) | Call self as a function.
  `axisinfo`(unit, axis[, format]) | Return a `matplotlib.units.AxisInfo` for unit and axis.
  `convert`(val, unit, axis) | Convert obj using unit for the specified axis.
  `default_units`(x, axis) | Return the default unit for x or `None` for the given axis.

  Methods Documentation

  __call__(func)

    Call self as a function.

  static axisinfo(unit, axis, format=None)

    Return a `matplotlib.units.AxisInfo` for unit and axis.

    Parameters:
      unit `UnitBase`

        The unit to format the axis for.

      axis `matplotlib.axis.Axis`

        The matplotlib axis being formatted.

      format `astropy.units.format.Base` subclass or `python:str` or `python:None`, optional

        The name of a format or a formatter class used to render the axis label. If `None`, the module-level default (`"latex_inline"`) is used.

  static convert(val, unit, axis)

    Convert obj using unit for the specified axis.

    If obj is a sequence, return the converted sequence. The output must be a sequence of scalars that can be used by the numpy array layer.

  static default_units(x, axis)

    Return the default unit for x or `None` for the given axis.