Spectrum

class gdt.core.plot.spectrum.Spectrum(data=None, background=None, canvas=None, **kwargs)[source]

Bases: GdtPlot

Class for plotting count spectra and count spectra paraphernalia.

This class can plot differential count spectra using energy information, or can plot a count spectrum based on raw energy channel.

Parameters:
  • data (EnergyBins, optional) – The count spectrum data to plot

  • background (BackgroundSpectrum, optional) – The background spectrum to plot

  • **kwargs – Options to pass to GdtPlot

Attributes Summary

ax

The matplotlib axes object for the plot

background

The count spectrum background plot element

canvas

The plotting canvas, if set upon initialization.

errorbars

The error bars plot element

fig

The matplotlib figure object

selections

The count spectrum selection plot element

spectrum

The count spectrum plot element

xlim

The plotting range of the x axis

xscale

The scale of the x axis, either 'linear' or 'log'.

ylim

The plotting range of the y axis.

yscale

The scale of the y axis, either 'linear' or 'log'.

Methods Summary

add_selection(data)

Add a selection to the plot.

remove_background()

Remove the background from the plot.

remove_data()

Remove the count spectrum from the plot.

remove_errorbars()

Remove the count spectrum errorbars from the plot.

remove_selections()

Remove the selections from the plot.

set_background(background)

Set the background plotting data.

set_data(data)

Set the count spectrum plotting data.

Attributes Documentation

ax

The matplotlib axes object for the plot

Type:

(matplotlib.axes)

background

The count spectrum background plot element

Type:

(SpectrumBackground)

canvas

The plotting canvas, if set upon initialization.

Type:

(Canvas Backend object)

errorbars

The error bars plot element

Type:

(HistoErrorbars)

fig

The matplotlib figure object

Type:

(matplotlib.figure)

selections

The count spectrum selection plot element

Type:

(list of HistoFilled)

spectrum

The count spectrum plot element

Type:

(Histo)

xlim

The plotting range of the x axis

Type:

(float, float)

xscale

The scale of the x axis, either ‘linear’ or ‘log’.

Type:

(str)

ylim

The plotting range of the y axis.

Type:

(float, float)

yscale

The scale of the y axis, either ‘linear’ or ‘log’.

Type:

(str)

Methods Documentation

add_selection(data)[source]

Add a selection to the plot. This adds a new selection to a list of existing selections.

Parameters:

data (EnergyBins) – The count spectrum data selections to plot

remove_background()[source]

Remove the background from the plot.

remove_data()[source]

Remove the count spectrum from the plot.

remove_errorbars()[source]

Remove the count spectrum errorbars from the plot.

remove_selections()[source]

Remove the selections from the plot.

set_background(background)[source]

Set the background plotting data. If a background already exists, this triggers a replot of the background.

Parameters:

background (BackgroundSpectrum) – The background spectrum to plot

set_data(data)[source]

Set the count spectrum plotting data. If a count spectrum already exists, this triggers a replot of the count spectrum.

If an EnergyBins object is used, this will plot a differential energy spectrum (count/s/keV), and if a ChannelBins object is used (i.e. no energy information), the count spectrum per channel is plotted.

:param data (EnergyBins or: ChannelBins): The data