# plot_data¶

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

Plot the data values.

Parameters
• id (int or str, optional) – The data set that provides the data. 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_data. 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)?

get_data_plot()

Return the data used by plot_data.

get_data_plot_prefs()

Return the preferences for plot_data.

get_default_id()

Return the default data set identifier.

plot()

Create one or more plot types.

sherpa.astro.ui.set_analysis()

Set the units used when fitting and displaying spectral data.

set_xlinear()

New plots will display a linear X axis.

set_xlog()

New plots will display a logarithmically-scaled X axis.

set_ylinear()

New plots will display a linear Y axis.

set_ylog()

New plots will display a logarithmically-scaled Y axis.

Notes

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

Examples

Plot the data from the default data set:

>>> plot_data()


Plot the data from data set 1:

>>> plot_data(1)


Plot the data from data set labelled “jet” and then overplot the “core” data set. The set_xlog command is used to select a logarithmic scale for the X axis.

>>> set_xlog("data")
>>> plot_data("jet")
>>> plot_data("core", overplot=True)


The following example requires that the Matplotlib backend is selected, and uses a Matplotlib function to create a subplot (in this case one filling the bottom half of the plot area) and then calls plot_data with the clearwindow argument set to False to use this subplot. If the clearwindow argument had not been used then the plot area would have been cleared and the plot would have filled the area.

>>> plt.subplot(2, 1, 2)
>>> plot_data(clearwindow=False)


Additional arguments can be given that are passed to the plot backend: the supported arguments match the keywords of the dictionary returned by get_data_plot_prefs. Examples include (for the Matplotlib backend): adding a “cap” to the error bars:

>>> plot_data(capsize=4)


changing the symbol to a square:

>>> plot_data(marker='s')


using a dotted line to connect the points:

>>> plot_data(linestyle='dotted')


and plotting multiple data sets on the same plot, using a log scale for the Y axis, setting the alpha transparency for each plot, and explicitly setting the colors of the last two datasets:

>>> plot_data(ylog=True, alpha=0.7)
>>> plot_data(2, overplot=True, alpha=0.7, color='brown')
>>> plot_data(3, overplot=True, alpha=0.7, color='purple')