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¶
|
Plot a detector pointing on the sky in equatorial, galactic, or spacecraft coordinates. |
|
Plot a line on the Earth. |
|
Plot a point or set of points on the Earth. |
|
Plot a histogram of the effective area of a detector response. |
|
Plot the Galactic Plane in equatorial, galactic, or spacecraft coordinates. |
|
A specialized colormap class that implements an alpha gradient. |
|
Base class for plots in the GDT. |
|
Plot a general heatmap (color gradient). |
|
Plot a rate histogram of either lightcurves or count spectra. |
|
Plot errorbars for lightcurves or count spectra. |
|
Plot a filled histogram. |
|
Plot a lightcurve background model with an error band. |
|
Plot a set of data with errors derived from the model variances. |
|
Plot a series of spectral model samples |
|
A base class representing a plot element. |
A collection class for plot elements. |
|
|
Plot the SAA polygon on the Earth. |
|
Plot an annulus on the sky in equatorial, galactic, or spacecraft coordinates. |
|
Plot a heatmap on the sky. |
|
Plot a circle on the sky in equatorial, galactic, or spacecraft coordinates. |
|
Plot a line on the sky in either equatorial, galactic, or spacecraft coordinates. |
|
Plot a set of points on the sky in equatorial, galactic, or spacecraft coordinates. |
|
Plot a polygon on the sky in equatorial, galactic, or spacecraft coordinates. |
|
Plot a count spectrum background model with an error band. |
|
Plot the sun on the sky in equatorial, galactic, or spacecraft coordinates |