Skip to content

Commit 9e2a3f1

Browse files
committed
add quantity_support call option
1 parent 9207374 commit 9e2a3f1

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
@@ -755,7 +755,7 @@ def __repr__(self):
755755
return result
756756

757757
def plot(self, ax=None, x_name='spectral axis', y_name='flux',
758-
**kwargs):
758+
set_quantity_support=True, **kwargs):
759759
"""
760760
Visualize this spectrum using matplotlib in "histogram style".
761761
@@ -770,6 +770,9 @@ def plot(self, ax=None, x_name='spectral axis', y_name='flux',
770770
y_name : str or None
771771
The name to use for the y axis (units will be automatically added)
772772
or None to not set the y axis label.
773+
set_quantity_support : bool
774+
If True, call `astropy.visualization.quantity_support` to ensure
775+
that the quantities in the plot are properly settable.
773776
774777
kwargs are passed into `~matplotlib.axes.Axes.plot`, except for
775778
``drawstyle`` or ``ds``.
@@ -783,6 +786,10 @@ def plot(self, ax=None, x_name='spectral axis', y_name='flux',
783786
# import is intentionally inside the method to make matplotlib an
784787
# "optional" dependency
785788
from matplotlib import pyplot as plt
789+
from astropy.visualization import quantity_support
790+
791+
if set_quantity_support:
792+
quantity_support()
786793

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

0 commit comments

Comments
 (0)