Skip to content

Commit 5a69ec8

Browse files
author
Mirco Panighel
committed
Add waterfall option in spectra plotting.
1 parent b5dd99e commit 5a69ec8

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

spym/plotting/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ class Plotting():
99
def __init__(self, spym_instance):
1010
self._spym = spym_instance
1111

12-
def plot(self, title=None, **kwargs):
12+
def plot(self, title=None, waterfall=False, waterfall_limit=15, **kwargs):
1313
''' Plot data with custom parameters using matplotlib.
1414
1515
Args:
1616
title: (optional) title of the figure (string). By default gives some basic information on the data plotted. Pass an empty string to disable it.
17+
waterfall: (optional) boolean determining if plot spectrum data as waterfall (default is False).
18+
waterfall_limit: (optional) number of spectra above which spectrum data is plotted as image instead of waterfall (default is 15).
1719
**kwargs: any argument accepted by xarray.plot() function.
1820
1921
'''
@@ -26,8 +28,13 @@ def plot(self, title=None, **kwargs):
2628

2729
# Set plot properties
2830
if attrs['interpretation'] == 'spectrum':
29-
# plot wraps matplotlib.pyplot.plot()
30-
plot = dr.plot.line(hue=dr.coords.dims[1], **kwargs)
31+
y_coord = dr.coords[dr.coords.dims[1]]
32+
# Check if plot spectra as waterfall or image
33+
if len(y_coord.data) <= waterfall_limit or waterfall:
34+
# plot wraps matplotlib.pyplot.plot()
35+
plot = dr.plot.line(hue=dr.coords.dims[1], **kwargs)
36+
else:
37+
plot = dr.plot(**kwargs)
3138

3239
elif attrs['interpretation'] == 'image':
3340
# plot is an instance of matplotlib.collections.QuadMesh

0 commit comments

Comments
 (0)