sherpa.astro.ui.plot_fit(id=None, replot=False, overplot=False, clearwindow=True, **kwargs)

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

This function creates a plot containing the data and the model (including any instrument response) for a data set.

  • id (int or str, optional) – The data set. If not given then the default identifier is used, as returned by get_default_id.

  • replot (bool, optional) – Set to True to use the values calculated by the last call to plot_fit. The default is False.

  • overplot (bool, optional) – If True then add the data to an exsiting plot, otherwise create a new plot. The default is False.

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


sherpa.utils.err.IdentifierErr – If the data set does not exist or a source expression has not been set.

See also


Return the data used to create the fit plot.


Return the default data set identifier.


Create one or more plot types.


Plot the fit results, and the residuals, for a data set.


Plot the fit results, and the ratio of data to model, for a data set.


Plot the fit results, and the residuals, for a data set.


Plot the data values.


Plot the model for a data set.


New plots will display a linear X axis.


New plots will display a logarithmically-scaled X axis.


New plots will display a linear Y axis.


New plots will display a logarithmically-scaled Y axis.


The additional arguments supported by plot_fit are the same as the keywords of the dictionary returned by get_data_plot_prefs.


Plot the fit results for the default data set:

>>> plot_fit()

Overplot the ‘core’ results on those from the ‘jet’ data set, using a logarithmic scale for the X axis:

>>> set_xlog()
>>> plot_fit('jet')
>>> plot_fit('core', overplot=True)

Keyword arguments can be given to override the plot preferences; for example the following sets the y axis to a log scale, but only for this plot:

>>> plot_fit(ylog=True)

The color can be changed for both the data and model using (note that the keyword name and supported values depends on the plot backend; this example assumes that Matplotlib is being used):

>>> plot_fit(color='orange')

Draw the fits for two datasets, setting the second one partially transparent (this assumes Matplotlib is used):

>>> plot_fit(1)
>>> plot_fit(2, alpha=0.7, overplot=True)