The sherpa.plot module

A visualization interface to Sherpa.

Classes provide access to common plotting tasks, which is done by the plotting backend defined in the options.plot_pkg setting of the Sherpa configuration file. Note that plot objects can be created and used even when only the sherpa.plot.backends.BasicBackend is available, it is just that no graphical display will be created.

Which backend is used?

When this module is first imported, Sherpa tries to import the backends installed with Sherpa in the order listed in the options.plot_pkg setting from the sherpa.rc startup file. The first module that imports successfully is set as the active backend. The following command prints the name of the backend:

>>> from sherpa import plot
>>> print(plot.backend.name)
pylab

Change the backend

After the initial import, the backend can be changed by loading one of the plotting backends shipped with sherpa (or any other module that provides the same interface):

>>> from sherpa.plot.pylab_backend import PylabBackend
>>> plot.backend = PylabBackend()

Creating a plot

A plot backend can act as a context manager to apply a specific backend to just one plot without globally changing the backend for the rest of the session:

>>> from sherpa.plot.pylab_backend import PylabBackend
>>> with PylabBackend():
...     # Now call the plot/overplot or contour/overcontour methods
...     obj.plot()   

This handles setting up the backend, handles any error handling, and then ends the session.

Classes

Plot()

Base class for line plots

Contour()

Base class for contour plots

Point()

Base class for point plots

Image()

Base class for image plots

Histogram()

Base class for histogram plots

HistogramPlot()

Base class for histogram-style plots with a prepare method.

DataHistogramPlot()

Create 1D histogram plots of data values.

ModelHistogramPlot()

Display a model as a histogram.

SourceHistogramPlot()

Display a source model as a histogram.

PDFPlot()

Display the probability density of an array.

CDFPlot()

Display the cumulative distribution of an array.

LRHistogram()

Derived class for creating 1D likelihood ratio distribution plots

SplitPlot([rows, cols])

Create multiple plots.

JointPlot([rows, cols])

Multiple plots that share a common axis

MultiPlot()

Combine multiple line-style plots.

DataPlot()

Create 1D plots of data values.

TracePlot()

ScatterPlot()

PSFKernelPlot()

Derived class for creating 1D PSF kernel data plots

DataContour()

Create contours of 2D data.

PSFKernelContour()

Derived class for creating 2D PSF Kernel contours

ModelPlot()

Create 1D plots of model values.

ComponentModelPlot()

Component model plots.

ComponentModelHistogramPlot()

Component model plots for histogram data.

ComponentTemplateModelPlot()

SourcePlot()

Create 1D plots of unconvolved model values.

ComponentSourcePlot()

Component source plots.

ComponentSourceHistogramPlot()

Component source plots for histogram data.

ComponentTemplateSourcePlot()

PSFPlot()

Derived class for creating 1D PSF kernel data plots

ModelContour()

Derived class for creating 2D model contours

PSFContour()

Derived class for creating 2D PSF contours

SourceContour()

Derived class for creating 2D model contours

FitPlot()

Combine data and model plots for 1D data.

FitContour()

Derived class for creating 2D combination data and model contours

BaseResidualPlot()

Residuals of model + data.

DelchiPlot()

Create plots of the delta-chi value per point.

ChisqrPlot()

Create plots of the chi-square value per point.

RatioPlot()

Create plots of the ratio of data to model per point.

ResidPlot()

Create plots of the residuals (data - model) per point.

BaseResidualHistogramPlot()

Residuals of model + data for histogram data.

DelchiHistogramPlot()

Create plots of the delta-chi value per point.

ChisqrHistogramPlot()

Create plot of the ChiSq residuals per point.

RatioHistogramPlot()

Create plots of the ratio value per point.

ResidHistogramPlot()

Create plots of the residual value per point.

BaseResidualContour()

Residuals of model + data for contour data.

ResidContour()

Derived class for creating 2D residual contours (data-model)

RatioContour()

Derived class for creating 2D ratio contours (data divided by model)

Confidence1D()

The base class for 1D confidence plots.

Confidence2D()

The base class for 2D confidence contours.

IntervalProjection()

The Interval-Projection method.

IntervalUncertainty()

The Interval-Projection method.

RegionProjection()

The Region-Projection method.

RegionUncertainty()

The Region-Projection method.

TemporaryPlottingBackend(new_backend)

Set the Sherpa plotting backend as a context, e.g. for a single plot.

Functions

set_backend(new_backend)

Set the Sherpa plotting backend.

Class Inheritance Diagram

Inheritance diagram of Plot, Contour, Point, Histogram, HistogramPlot, DataHistogramPlot, ModelHistogramPlot, SourceHistogramPlot, PDFPlot, CDFPlot, LRHistogram, SplitPlot, JointPlot, MultiPlot, DataPlot, TracePlot, ScatterPlot, PSFKernelPlot, DataContour, PSFKernelContour, ModelPlot, ComponentModelPlot, ComponentModelHistogramPlot, ComponentTemplateModelPlot, SourcePlot, ComponentSourcePlot, ComponentSourceHistogramPlot, ComponentTemplateSourcePlot, PSFPlot, ModelContour, PSFContour, SourceContour, FitPlot, FitContour, BaseResidualPlot, DelchiPlot, ChisqrPlot, RatioPlot, ResidPlot, BaseResidualHistogramPlot, DelchiHistogramPlot, ChisqrHistogramPlot, RatioHistogramPlot, ResidHistogramPlot, BaseResidualContour, ResidContour, RatioContour, Confidence1D, Confidence2D, IntervalProjectionWorker, IntervalProjection, IntervalUncertaintyWorker, IntervalUncertainty, RegionProjectionWorker, RegionProjection, RegionUncertaintyWorker, RegionUncertainty