FitPlot

class sherpa.plot.FitPlot[source] [edit on github]

Bases: Plot

Combine data and model plots for 1D data.

dataplot

The Sherpa plot object used to display the data.

modelplot

The Sherpa plot object used to display the model.

Examples

If dplot and mplot are data and model plots respectively, such as those created in the examples for DataPlot and ModelPlot, then a combined plot can be created with:

>>> from sherpa.data import Data1D
>>> from sherpa.models.basic import StepLo1D
>>> from sherpa.plot import DataPlot, ModelPlot, FitPlot
>>> data = Data1D('a dataset', [10, 20, 25], [2, -7, 4])
>>> dplot = DataPlot()
>>> fplot = FitPlot()
>>> model = StepLo1D()
>>> model.xcut = 19
>>> mplot = ModelPlot()
>>> dplot.prepare(data)
>>> mplot.prepare(data, model)
>>> fplot.prepare(dplot, mplot)
>>> fplot.plot()

Keyword arguments can be given in the plot call, and these are passed through to both the data and model plots (in the following example the Matplotlib backend is assumed to be in use):

>>> fplot.plot(color='k')

Attributes Summary

plot_prefs

The preferences for the plot.

Methods Summary

hline(y[, xmin, xmax, linecolor, linestyle, ...])

Draw a line at constant y, extending over the plot.

overplot(*args, **kwargs)

Add the data to an existing plot.

plot([overplot, clearwindow])

Plot the data.

prepare(dataplot, modelplot)

Create the data to plot

vline(x[, ymin, ymax, linecolor, linestyle, ...])

Draw a line at constant x, extending over the plot.

Attributes Documentation

plot_prefs = {}

The preferences for the plot. Note that the display for the data and model plots are controlled by the preferences for the dataplot and modelplot objects, so this is currently unused.

Methods Documentation

static hline(y, xmin=0, xmax=1, linecolor=None, linestyle=None, linewidth=None, overplot=False, clearwindow=True) [edit on github]

Draw a line at constant y, extending over the plot.

overplot(*args, **kwargs) [edit on github]

Add the data to an existing plot.

This is the same as calling the plot method with overplot set to True.

See also

plot

plot(overplot=False, clearwindow=True, **kwargs)[source] [edit on github]

Plot the data.

This will plot the data sent to the prepare method.

Parameters:
  • overplot (bool, optional) – If True then add the data to an existing plot, otherwise create a new plot.

  • clearwindow (bool, optional) – Should the existing plot area be cleared before creating this new plot (e.g. for multi-panel plots)?

  • **kwargs – These values are passed on to the plot backend, and must match the names of the keys of the object’s plot_prefs dictionary. They are sent to both the dataplot and modelplot instances.

See also

prepare, overplot

prepare(dataplot, modelplot)[source] [edit on github]

Create the data to plot

Parameters:
  • dataplot – The Sherpa plot object representing the data (normally a DataPlot instance).

  • modelplot – The Sherpa plot object representing the model (normally a ModelPlot instance).

See also

plot

static vline(x, ymin=0, ymax=1, linecolor=None, linestyle=None, linewidth=None, overplot=False, clearwindow=True) [edit on github]

Draw a line at constant x, extending over the plot.