Skip to content

Commit 4ef4dcb

Browse files
committed
add quantity_support call option
1 parent e4cfccc commit 4ef4dcb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

specutils/spectra/spectrum1d.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ def __repr__(self):
770770
return result
771771

772772
def plot(self, ax=None, x_name='spectral axis', y_name='flux',
773-
**kwargs):
773+
set_quantity_support=True, **kwargs):
774774
"""
775775
Visualize this spectrum using matplotlib in "histogram style".
776776
@@ -785,6 +785,9 @@ def plot(self, ax=None, x_name='spectral axis', y_name='flux',
785785
y_name : str or None
786786
The name to use for the y axis (units will be automatically added)
787787
or None to not set the y axis label.
788+
set_quantity_support : bool
789+
If True, call `astropy.visualization.quantity_support` to ensure
790+
that the quantities in the plot are properly settable.
788791
789792
kwargs are passed into `~matplotlib.axes.Axes.plot`, except for
790793
``drawstyle`` or ``ds``.
@@ -798,6 +801,10 @@ def plot(self, ax=None, x_name='spectral axis', y_name='flux',
798801
# import is intentionally inside the method to make matplotlib an
799802
# "optional" dependency
800803
from matplotlib import pyplot as plt
804+
from astropy.visualization import quantity_support
805+
806+
if set_quantity_support:
807+
quantity_support()
801808

802809
if 'drawstyle' in kwargs or 'ds' in kwargs:
803810
raise TypeError("cannot set draw style in a spectrum's plot_quick")

0 commit comments

Comments
 (0)