Plotting classes and functions#
Classes and functions for plotting spectra and SDFITS data
SpecPlot#
Plot a spectrum using matplotlib
- class dysh.plot.specplot.InteractiveSpanSelector(ax)[source]#
Bases:
objectMethods
clear_region
clear_regions
get_selected_regions
on_key_press
on_motion
on_press
on_release
onselect
- class dysh.plot.specplot.SpectrumPlot(spectrum, **kwargs)[source]#
Bases:
PlotBaseThe SpectrumPlot class is for simple plotting of a
Spectrumusing matplotlib functions. Plots attributes are modified using keywords (**kwargs) described below. SpectrumPlot will attempt to make smart default choices for the plot if no additional keywords are given.- Parameters:
- spectrum
Spectrum The spectrum to plot
- spectrum
- Attributes:
Methods
clear_overlays([blines, oshows])Clear Overlays from the plot.
freex()"Free the X-axis if limits have been set.
freexy()Free the X and Y axes simultaneously.
freey()Free the Y-axis if limits have been set.
oshow(spectra[, color, linestyle])Add
spectrato the current plot.plot([show_header, select, oshow])Plot the spectrum.
refresh()Refresh the plot
reset()Reset the plot keyword arguments to their defaults.
savefig(file, **kwargs)Save the plot
get_selected_regions
- Other Parameters:
- xaxis_unitstr or
Unit The units to use on the x-axis, e.g. “km/s” to plot velocity
- yaxis_unitstr or
Unit The units to use on the y-axis
- xminfloat
Minimum x-axis value, in
xaxis_unit- xmaxfloat
Maximum x-axis value, in
yaxis_unit- yminfloat
Minimum y-axis value, in
xaxis_unit- ymaxfloat
Maximum y-axis value, in
yaxis_unit- xlabelstr
x-axis label
- ylabelstr
y-axis label
- gridbool
Show a plot grid or not
- figsizetuple
Figure size (see matplotlib)
- linewidthfloat
Line width, default: 2.0. lw also works
- linestylestr
Line style, default ‘steps-mid’. ls also works
- colorstr
Line color, c also works
- titlestr
Plot title
- vel_framestr
The velocity frame (see VELDEF FITS Keyword)
- doppler_convention: str
The velocity convention (see VELDEF FITS Keyword)
- xaxis_unitstr or
- clear_overlays(blines=True, oshows=True)[source]#
Clear Overlays from the plot.
- Parameters:
- blinesbool
Remove only baseline models overlaid on the plot. Default: True
- freex()[source]#
“Free the X-axis if limits have been set. Resets the limits to be the span of the spectrum.
- freey()[source]#
Free the Y-axis if limits have been set. Autoscales the Y-axis according to your matplotlib configuration.
- oshow(spectra, color=None, linestyle=None)[source]#
Add
spectrato the current plot.- Parameters:
- spectralist of
dysh.spectra.spectrum.Spectrumordysh.spectra.spectrum.Spectrum Spectra to add to the plot.
- colorlist of valid
matplotlibcolors ormatplotlibcolor Colors for the spectra. There must be one element per spectra.
- linestylelist of valid
matplotliblinestyles ormatplotliblinestyle Linestyles for the spectra. There must be one element per spectra.
- spectralist of
- plot(show_header=True, select=True, oshow=None, **kwargs)[source]#
Plot the spectrum.
- Parameters:
- show_headerbool
Show informational header.
- selectbool
Allow selecting regions via click and drag.
- oshowlist or
Spectrum Spectra to overlay in the plot.
- Other Parameters:
- xaxis_unitstr or
Unit The units to use on the x-axis, e.g. “km/s” to plot velocity
- yaxis_unitstr or
Unit The units to use on the y-axis
- xminfloat
Minimum x-axis value, in
xaxis_unit- xmaxfloat
Maximum x-axis value, in
yaxis_unit- yminfloat
Minimum y-axis value, in
xaxis_unit- ymaxfloat
Maximum y-axis value, in
yaxis_unit- xlabelstr
x-axis label
- ylabelstr
y-axis label
- gridbool
Show a plot grid or not
- figsizetuple
Figure size (see matplotlib)
- linewidthfloat
Line width, default: 2.0. lw also works
- linestylestr
Line style, default ‘steps-mid’. ls also works
- colorstr
Line color, c also works
- titlestr
Plot title
- vel_framestr
The velocity frame (see VELDEF FITS Keyword)
- doppler_convention: str
The velocity convention (see VELDEF FITS Keyword)
- xaxis_unitstr or
ScanPlot#
Plot a spectrum using matplotlib
- class dysh.plot.scanplot.ScanPlot(scanblock_or_scan, **kwargs)[source]#
Bases:
PlotBaseThe ScanPlot class is for simple plotting of a
ScanorScanBlockusing matplotlib functions. Plots attributes are modified using keywords (**kwargs) described below SpectrumPlot will attempt to make smart default choices for the plot if no additional keywords are given.- Parameters:
- scanblock_or_scan
ScanorScanBlock The scan or scanblock to plot.
- **kwargsdict
Plot attribute keyword arguments, see below.
- scanblock_or_scan
- Attributes:
axisThe underlying
AxesobjectfigureThe underlying
Figureobject
Methods
plot([spectral_unit])Plot the scan.
refresh()Refresh the plot
reset()Reset the plot keyword arguments to their defaults.
savefig(file, **kwargs)Save the plot
set_clim(vmin, vmax)Set the vmin and vmax parameters of the image.
set_cmap([cmap])Set the cmap of the image.
set_interpolation([interpolation])Set the interpolation of the image.
- Other Parameters:
- spectral_unitstr
The units to use on the frequency axis. Can be ‘MHz’ or ‘GHz’.
- plot(spectral_unit=None, **kwargs)[source]#
Plot the scan.
- Parameters:
- spectral_unit
Unit The units to use on the frequency axis. Default: MHz if below 1 GHz, GHz if above.
- **kwargsvarious
keyword=value arguments (need to describe these in a central place)
- spectral_unit
- set_clim(vmin, vmax)[source]#
Set the vmin and vmax parameters of the image.
- Parameters:
- vminfloat
The minimum value of the color scale.
- vmaxfloat
The maximum value of the color scale.