Plot Element Classes (plot)

In the gdt.core.plot.plot module, there are two important base classes to be aware of.

  • GdtPlot is the base class for all plots in the GDT. It contains the basic functionality to instantiate plots and provide ways to dynamically update them.

  • PlotElement is the base class representing a single plot element, such as a lightcurve histogram or a polygon plotted on the sky. These are generally wrappers around the lower-level lib functions with additional functions to enable dynamic updating.

For Developers:

For the PlotElement base class, the basic plot attributes provided are the alpha, color, visible, and zorder. These attributes can be updated dynamically. Derived classes can add other attributes.

An example of how to subclass PlotElement with an extra linestyle attribute:

>>> from gdt.core.plot.plot import PlotElement
>>> class MyPlotElement(PlotElement):
>>>     def __init__(self, data, ax, color='C0', alpha=1.0, **kwargs):
>>>         # data is some data that we want to plot
>>>         # ax is the matplotlib axis we are plotting to
>>>
>>>         super().__init__(color=color, alpha=alpha)
>>>         self._kwargs = kwargs
>>>
>>>         # artists is some iterable of matplotlib plot artists
>>>         artists =  _create(data, ax)
>>>
>>>         # matplotlib is not consistent in how artists are represented,
>>>         # so we should sanitize (or flatten) to a simple list with
>>>         # this base class method
>>>         self._artists = self._sanitize_artists(artists)
>>>
>>>     def _create(self, data, ax):
>>>         artists = function_calling_matplotlib(data, color=self.color,
>>>                                               alpha=self.alpha, **self.kwargs)
>>>         return artists
>>>
>>>     @property
>>>     def linestyle(self):
>>>         return self.artists[0].get_linestyle()
>>>
>>>     @linestyle.setter
>>>     def linestyle(self, val):
>>>         for artist in self.artists:
>>>             artist.set_linestyle(val)

In this example, we store other keyword arguments internally, and then the actual plotting is performed in _create(), where we create a matplotlib plotting object (or some collection of objects). This example assumes that linestyle should be the same for all matplotlib artists contained in MyPlotElement.

Reference/API

gdt.core.plot.plot Module

Classes

DetectorPointing(x, y, radius, det, ax[, ...])

Plot a detector pointing on the sky in equatorial, galactic, or spacecraft coordinates.

EarthLine(lat, lon, proj[, color, alpha])

Plot a line on the Earth.

EarthPoints(lat, lon, proj[, color, alpha, ...])

Plot a point or set of points on the Earth.

EffectiveArea(bins, ax[, color, alpha, ...])

Plot a histogram of the effective area of a detector response.

GalacticPlane(ax[, flipped, frame, color, ...])

Plot the Galactic Plane in equatorial, galactic, or spacecraft coordinates.

GdtCmap(name[, alpha_min, alpha_max, ...])

A specialized colormap class that implements an alpha gradient.

GdtPlot([figsize, dpi, canvas, interactive, ax])

Base class for plots in the GDT.

Heatmap(x, y, heatmap, ax[, colorbar, ...])

Plot a general heatmap (color gradient).

Histo(bins, ax[, color, alpha, label])

Plot a rate histogram of either lightcurves or count spectra.

HistoErrorbars(bins, ax[, color, alpha])

Plot errorbars for lightcurves or count spectra.

HistoFilled(bins, ax[, color, alpha, fill_alpha])

Plot a filled histogram.

LightcurveBackground(backrates, ax[, color, ...])

Plot a lightcurve background model with an error band.

ModelData(x, y, xerr, yerr, ax[, ulmask, ...])

Plot a set of data with errors derived from the model variances.

ModelSamples(x, y_list, ax[, color, alpha, ...])

Plot a series of spectral model samples

PlotElement([color, alpha])

A base class representing a plot element.

PlotElementCollection()

A collection class for plot elements.

SAA(saa_def, proj, ax[, color, alpha])

Plot the SAA polygon on the Earth.

SkyAnnulus(x, y, radius, width, ax[, ...])

Plot an annulus on the sky in equatorial, galactic, or spacecraft coordinates.

SkyHeatmap(x, y, heatmap, ax[, flipped, ...])

Plot a heatmap on the sky.

SkyCircle(x, y, radius, ax[, flipped, ...])

Plot a circle on the sky in equatorial, galactic, or spacecraft coordinates.

SkyLine(x, y, ax[, flipped, frame, color, alpha])

Plot a line on the sky in either equatorial, galactic, or spacecraft coordinates.

SkyPoints(x, y, ax[, flipped, frame, color, ...])

Plot a set of points on the sky in equatorial, galactic, or spacecraft coordinates.

SkyPolygon(x, y, ax[, flipped, frame, ...])

Plot a polygon on the sky in equatorial, galactic, or spacecraft coordinates.

SpectrumBackground(backspec, ax[, color, ...])

Plot a count spectrum background model with an error band.

Sun(x, y, ax[, flipped, frame, alpha])

Plot the sun on the sky in equatorial, galactic, or spacecraft coordinates

Class Inheritance Diagram

Inheritance diagram of gdt.core.plot.plot.DetectorPointing, gdt.core.plot.plot.EarthLine, gdt.core.plot.plot.EarthPoints, gdt.core.plot.plot.EffectiveArea, gdt.core.plot.plot.GalacticPlane, gdt.core.plot.plot.GdtCmap, gdt.core.plot.plot.GdtPlot, gdt.core.plot.plot.Heatmap, gdt.core.plot.plot.Histo, gdt.core.plot.plot.HistoErrorbars, gdt.core.plot.plot.HistoFilled, gdt.core.plot.plot.LightcurveBackground, gdt.core.plot.plot.ModelData, gdt.core.plot.plot.ModelSamples, gdt.core.plot.plot.PlotElement, gdt.core.plot.plot.PlotElementCollection, gdt.core.plot.plot.SAA, gdt.core.plot.plot.SkyAnnulus, gdt.core.plot.plot.SkyHeatmap, gdt.core.plot.plot.SkyCircle, gdt.core.plot.plot.SkyLine, gdt.core.plot.plot.SkyPoints, gdt.core.plot.plot.SkyPolygon, gdt.core.plot.plot.SpectrumBackground, gdt.core.plot.plot.Sun