Skip to main content
`Ctrl`+`K`

# quantity_support

astropy.visualization.quantity_support(format=None)

  Enable support for plotting `astropy.units.Quantity` instances in matplotlib.

  May be (optionally) used with a `with` statement.

      >>> import matplotlib.pyplot as plt
      >>> from astropy import units as u
      >>> from astropy import visualization
      >>> with visualization.quantity_support():
      ...     fig, ax = plt.subplots()
      ...     ax.plot([1, 2, 3] * u.m)
      ...
      ...     ax.plot([101, 125, 150] * u.cm)
      ...
      ...     ax.yaxis.set_units(u.km)
      ...     plt.draw()

  The default axis unit is inferred from the first plot using a Quantity. To override it, you can explicitly set the axis unit using `matplotlib.axis.Axis.set_units()`, for example, `ax.yaxis.set_units(u.km)`.

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

      The name of a format or a formatter class. If not provided, defaults to `latex_inline`.