Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog/188.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add a ``peek()`` method to ``GenericSpectrogram``, which gives it a quick-look plotting functionality
similar to ``sunpy.map.Map.peek()`` and ``radiospectra.spectrum.Spectrum.peek()``.
23 changes: 23 additions & 0 deletions radiospectra/spectrogram/spectrogrambase.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,26 @@ def __repr__(self):
f" {self.wavelength.min} - {self.wavelength.max},"
f" {self.start_time.isot} to {self.end_time.isot}>"
)

def peek(self, **kwargs):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably use @peek_show like in sunpy so the figure isn't returned to have a similar API

"""
Displays a quick-look plot of the Spectrogram with a colorbar.

Parameters
----------
**kwargs : `dict`
Any additional keyword arguments are passed to `~radiospectra.spectrogram.GenericSpectrogram.plot`.

Returns
-------
`matplotlib.figure.Figure`
The figure object containing the plot.
"""
import matplotlib.pyplot as plt

figure = plt.figure()
axes = figure.add_subplot(111)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this is needed

Suggested change
axes = figure.add_subplot(111)
axes = figure.add_subplot()

ret = self.plot(axes=axes, **kwargs)
figure.colorbar(ret)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be an option in the method e.g. show_coloarbar=True

figure.show()
return figure