Skip to content

Commit

Permalink
add quantity_support call option
Browse files Browse the repository at this point in the history
  • Loading branch information
eteq committed Nov 15, 2023
1 parent e4cfccc commit 4ef4dcb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion specutils/spectra/spectrum1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def __repr__(self):
return result

def plot(self, ax=None, x_name='spectral axis', y_name='flux',
**kwargs):
set_quantity_support=True, **kwargs):
"""
Visualize this spectrum using matplotlib in "histogram style".
Expand All @@ -785,6 +785,9 @@ def plot(self, ax=None, x_name='spectral axis', y_name='flux',
y_name : str or None
The name to use for the y axis (units will be automatically added)
or None to not set the y axis label.
set_quantity_support : bool
If True, call `astropy.visualization.quantity_support` to ensure
that the quantities in the plot are properly settable.
kwargs are passed into `~matplotlib.axes.Axes.plot`, except for
``drawstyle`` or ``ds``.
Expand All @@ -798,6 +801,10 @@ def plot(self, ax=None, x_name='spectral axis', y_name='flux',
# import is intentionally inside the method to make matplotlib an
# "optional" dependency
from matplotlib import pyplot as plt
from astropy.visualization import quantity_support

if set_quantity_support:
quantity_support()

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

Check warning on line 810 in specutils/spectra/spectrum1d.py

View check run for this annotation

Codecov / codecov/patch

specutils/spectra/spectrum1d.py#L810

Added line #L810 was not covered by tests
Expand Down

0 comments on commit 4ef4dcb

Please sign in to comment.