DataPlot¶
-
class
sherpa.astro.plot.
DataPlot
[source] [edit on github]¶ Bases:
sherpa.plot.Plot
Create 1D plots of data values.
-
plot_prefs
¶ The preferences for the plot.
Type: dict
-
x
¶ The X value for each point (the independent variable).
Type: array_like
-
y
¶ The Y value for each point (the dependent variable).
Type: array_like
-
xerr
¶ The half-width of each X “bin”, if set.
Type: array_like
-
yerr
¶ The error on the Y value, if set.
Type: array_like
-
xlabel, ylabel, title
Plot labels.
Type: str
Examples
Plot up an example dataset. The default appearance is to draw a symbol at each point, but no line connecting the points (the actual choice depends on the plot backend):
>>> from sherpa.data import Data1D >>> from sherpa.plot import DataPlot >>> data = Data1D('a dataset', [10, 20, 25], [2, -7, 4]) >>> dplot = DataPlot() >>> dplot.prepare(data) >>> dplot.plot()
The plot attributes can be changed to adjust the appearance of the plot, and the data re-drawn. The following also shows how the plot preferences can be over-ridden to turn off the points and draw a dotted line connecting the points (this assumes that the Matplotlib backend is in use):
>>> dplot.xlabel = 'length' >>> dplot.ylabel = 'data values' >>> dplot.plot(marker=' ', linestyle='dashed')
Attributes Summary
plot_prefs
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
(data[, stat])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
= {}
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
(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 exsiting 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.
See also
- overplot (bool, optional) – If
-
prepare
(data, stat=None)[source] [edit on github]¶ Create the data to plot
Parameters: - data – The Sherpa data object to display (it is assumed to be one dimensional).
- stat (optional) – The Sherpa statistics object to use to add Y error bars if the data has none.
See also
-
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.
-