class xspec.PlotManager(deviceStr)

Xspec plotting class.

PyXspec automatically creates a single object of this class, named Plot.


  • __call__ (the ‘()’ operator)
  • addCommand
  • backgroundVals
  • delCommand
  • iplot
  • model
  • noID
  • setGroup
  • setID
  • setRebin
  • show
  • x
  • xErr
  • y
  • yErr


  • add
  • area
  • background
  • commands
  • device
  • perHz
  • redshift
  • splashPage
  • xAxis
  • xLog
  • yLog

Display the plot.

Input 1 or more plot command strings.


# Single Plots: 
# Multiple Plots (or single plots taking additional arguments):
Plot("data model resid")
Plot("data","model m1")  # Plots data and a model named "m1".
# To repeat a plot using the previously entered arguments, simply do: 

Add a plot command [string] to the end of the plot commands list.

backgroundVals(plotGroup=1, plotWindow=1)

Return a list of background data values for a plot group and plot window

Background value arrays only exist for data plots when the Plot.background flag is set to True.


Remove a plot command by (1-based) number [int].

This is intended for removal of single commands. To remove ALL commands, set the Plot.commands attribute to an empty tuple, ie:

>>> Plot.commands = ()

Display the plot and leave it in interactive plotting mode.

This function takes the same arguments and syntax as when displaying plots in the regular mode (through Plot’s __call__ method). Examples:

Plot.iplot("data")   # 1-panel data plot
Plot.iplot("data model")    # 2-panel data and model
Plot.iplot()                # Repeats the previous plot.
model(plotGroup=1, plotWindow=1)

Return a list of Y-coordinate model values for a plot group and plot window


Turn off the plotting of line IDs.


Define a range of spectra to be in the same plot group.

Input argument is a string specifying one or more ranges, delimited by commas and/or spaces. Examples:

# Spectra 1-3 in plot group 1, 4-6 in group 2.
Plot.setGroup("1-3  4-6")

# Spectra 1, 2, and 4 are each now in their own group.           
Plot.setGroup("1,2 4")

# All spectra are in a single plot group. 

# If input argument is Python's 'None' variable, all
# plot grouping will be removed.  
setID(temperature=None, emissivity=None, redshift=None)

Switch on plotting of line IDs.

All input arguments are floats and are optional. If they are omitted they will retain their previous values.

  • temperature: Selects the temperature of the APEC line list.
  • emissitivity: Only lines with emissivities above this setting will be displayed.
  • redshift: Line display will be redshifted by this amount.

To turn off plotting of line IDs, use the noID() function.

setRebin(minSig=None, maxBins=None, groupNum=None, errType=None)

Define characteristics used in rebinning the data (for plotting purposes ONLY).

All input arguments are optional. If they are omitted they will retain their previous values.

  • minSig: Bins will be combined until this minimum significance is reached (in units of sigma). [float]
  • maxBins: The maximum number of bins to combine in attempt to reach minSig. [int]
  • groupNum: The plot group number to which this setting applies. If number is negative, it will apply to ALL plot groups. [int]
  • errType: Specifies how to calculate the error bars on the new bins. Valid entries are “quad”, “sqrt”, “poiss-1”,”poiss-2”, “poiss-3”. [string] See the “setplot” description in the XSPEC manual for more information.

Display current plot settings

x(plotGroup=1, plotWindow=1)

Return a list of X-coordinate data values for a plot group and plot window

xErr(plotGroup=1, plotWindow=1)

Return a list of X-coordinate errors for a plot group and plot window

y(plotGroup=1, plotWindow=1)

Return a list of Y-coordinate data values for a plot group and plot window

yErr(plotGroup=1, plotWindow=1)

Return a list of Y-coordinate errors for a plot group and plot window


Turn on/off the display of individual additive components [bool].


Toggle displaying the data divided by the response effective area for each channel [bool].


Toggle displaying the background spectrum (if any) when plotting data [bool].

Custom plot commands to be appended to Xspec-generated

Get: Returns a tuple of the currently entered command strings.

Set: Replaces all commands with the new tuple of strings.

To remove ALL plot commands, set to an empty tuple, ie:
>>> Plot.commands = ()

For inserting and deleting individual commands, use addCommand and delCommand functions.


The plotting device name [string].


Toggle displaying Y-axis units per Hz when using wavelength units for X-axis [bool].


Apply a redshift to the X-axis energy or wavelength values [float].

This will multiply X-axis energies by a factor of (1+z) to allow for viewing in the source frame. Y-axis values will be equally affected in plots which are normalized by energy or wavelength. Note that this is not connected in any way to redshift parameters in the model (or the setplot id redshift parameter) and should only be used for illustrative purposes.


When set to False, the usual XSPEC version and build data information will not be printed to the screen when the first plot window is initially opened [bool].


X-Axis Units [string].

Valid options are: “channel”, (energies) “keV”, “MeV”, “GeV”, “Hz”, (wavelengths) “angstrom”, “cm”, “micron”, nm”

These are case-insensitive and may be abbreviated.

This setting also affects the ignore/notice range interpretation.


Set the x-axis to logarithmic or linear for energy or wavelength plots [bool].

xLog has no effect on plots in channel space. xLog and yLog will not work for model-related plots (eg. model, ufspec, and their variants) as their axes are always set to log scale.


See xLog.