plot
- sherpa.ui.plot(*args, **kwargs)
Create one or more plot types.
The plot function creates one or more plots, depending on the arguments it is sent: a plot type, followed by optional identifiers, and this can be repeated. If no data set identifier is given for a plot type, the default identifier - as returned by
get_default_id- is used.Changed in version 4.15.0: A number of labels, such as “bkgfit”, are marked as deprecated and using them will cause a warning message to be displayed, indicating the new label to use.
Changed in version 4.12.2: Keyword arguments, such as alpha and ylog, can be sent to each plot.
- Raises:
sherpa.utils.err.ArgumentErr – The label is invalid.
See also
get_default_idReturn the default data set identifier.
sherpa.astro.ui.set_analysisSet the units used when fitting and displaying spectral data.
set_xlinearNew plots will display a linear X axis.
set_xlogNew plots will display a logarithmically-scaled X axis.
set_ylinearNew plots will display a linear Y axis.
set_ylogNew plots will display a logarithmically-scaled Y axis.
Notes
The supported plot types depend on the data set type, and include the following list. There are also individual functions, with
plot_prepended to the plot type, such asplot_data. There are also several multiple-plot commands, such asplot_fit_ratio,plot_fit_resid, andplot_fit_delchi.arfThe ARF for the data set (only for
DataPHAdata sets).bkgThe background.
bkg_chisqrThe chi-squared statistic calculated for each bin when fitting the background.
bkg_delchiThe residuals for each bin, calculated as (data-model) divided by the error, for the background.
bkg_fitThe data (as points) and the convolved model (as a line), for the background data set.
bkg_modelThe convolved background model.
bkg_ratioThe residuals for each bin, calculated as data/model, for the background data set.
bkg_residThe residuals for each bin, calculated as (data-model), for the background data set.
bkg_sourceThe un-convolved background model.
chisqrThe chi-squared statistic calculated for each bin.
dataThe data (which may be background subtracted).
delchiThe residuals for each bin, calculated as (data-model) divided by the error.
fitThe data (as points) and the convolved model (as a line).
kernelThe PSF kernel associated with the data set.
modelThe convolved model.
model_componentPart of the full model expression (convolved).
model_componentsParts of the full model expression (convolved).
orderPlot the model for a selected response
psfThe unfiltered PSF kernel associated with the data set.
ratioThe residuals for each bin, calculated as data/model.
residThe residuals for each bin, calculated as (data-model).
sourceThe un-convolved model.
source_componentPart of the full model expression (un-convolved).
source_componentsParts of the full model expression (un-convolved).
The plots can be specialized for a particular data type, such as the
set_analysiscommand controlling the units used for PHA data sets.See the documentation for the individual routines for information on how to configure the plots.
The plot capabilities depend on what plotting backend, if any, is installed. If there is none available, a warning message will be displayed when
sherpa.uiorsherpa.astro.uiis imported, and theplotset of commands will not create any plots. The choice of back end is made by changing theoptions.plot_pkgsetting in the Sherpa configuration file.The keyword arguments are sent to each plot (so care must be taken to ensure they are valid for all plots).
Examples
Plot the data for the default data set. This is the same as
plot_data.>>> plot("data")
Plot the data for data set 2.
>>> plot("data", 2)
Plot the data and ARF for the default data set, in two seaparate plots.
>>> plot("data", "arf")
Plot the fit (data and model) for data sets 1 and 2, in two separate plots.
>>> plot("fit", 1, "fit", 2)
Plot the fit (data and model) for data sets “fit” and “jet”, in two separate plots.
>>> plot("fit", "nucleus", "fit", "jet")
Draw the data and model plots both with a log-scale for the y axis:
>>> plot("data", "model", ylog=True)
Plot the backgrounds for dataset 1 using the “up” and “down” components (in this case the background identifier):
>>> plot("bkg", 1, "up", "bkg", 1, "down")