get_bkg_fit_plot

sherpa.astro.ui.get_bkg_fit_plot(id: IdType | None = None, bkg_id: IdType | None = None, recalc: bool = True, copy: bool = True)

Return the data used by plot_bkg_fit.

Changed in version 4.19.0: The plot object is now copied by default. To get the previous behaviour set the copy attribute to False.

Parameters:
idint, str, or None, optional

The data set that provides the data. If not given then the default identifier is used, as returned by get_default_id.

bkg_idint, str, or None, optional

Identify the background component to use, if there are multiple ones associated with the data set.

recalcbool, optional

If False then the results from the last call to plot_bkg_fit (or get_bkg_fit_plot) are returned, otherwise the data is re-generated.

copybool, optional

Is the plot object copied before being returned? If so then the plot attributes will not be changed by multiple calls to this routine.

Returns:
modela sherpa.astro.plot.BkgFitPlot instance

An object representing the data used to create the plot by plot_bkg_fit.

Raises:
sherpa.utils.err.ArgumentErr

If the data set does not contain PHA data.

sherpa.utils.err.IdentifierErr

If the bkg_id parameter is invalid.

sherpa.utils.err.ModelErr

If no model expression has been created for the background data.

See also

get_bkg_plot

Return the data used by plot_bkg.

get_bkg_model_plot

Return the data used by plot_bkg_model.

plot_bkg_fit

Plot the fit results (data, model) for the background of a PHA data set.

Examples

Create the data needed to create the “fit plot” for the background of the default data set and display it:

>>> bplot = get_bkg_fit_plot()
>>> print(bplot)

Return the plot data for data set 2, and then use it to create a plot:

>>> b2 = get_bkg_fit_plot(2)
>>> b2.plot()

The fit plot consists of a combination of a data plot and a model plot, which are captured in the dataplot and modelplot attributes of the return value. These can be used to display the plots individually, such as:

>>> b2.dataplot.plot()
>>> b2.modelplot.plot()

or, to combine the two:

>>> b2.dataplot.plot()
>>> b2.modelplot.overplot()

Return the plot data for the second background component to the “jet” data set:

>>> bplot = get_bkg_fit_plot('jet', bkg_id=2)