Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2013

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.9 Sherpa v1


Context: data


Return a plot, contour, or image of the data, or the associated preferences


get_data_plot( [id] )
get_data_contour( [id] )
get_data_image( [id] )


  • id - the id of the dataset to use; if not given, uses the default dataset id (id=1 by default, see "ahelp get_default_id")


The get_data_plot command returns a data plot object which holds references to various plot preferences and data arrays. The attributes are:

Field name Description
x The bin centers (independent variable)
y The value of the dependent variable
yerr The error on y
xerr The half-width of the bin
xlabel The label for the X axis
ylabel The label for the Y axis
title The plot title
plot_prefs The preferences for the plot

Note that the show_data command ("ahelp show_data") is recommended to simply print the current data to the screen.


The get_data_plot_prefs command returns a dictionary of data plot preferences. For example:

{'errstyle': 'line',
 'linestyle': 0,
 'symbolfill': False,
 'symbolsize': 3,
 'symbolstyle': 4,
 'yerrorbars': True}

Users can change preferences as desired in the set returned by this function, as shown below in the examples. These preferences changes the appearance of data plotted using the following commands: plot_data(), plot_bkg(), plot_ratio(), and the "fit" versions of these commands, such as plot_fit(), plot_bkg_fit(), and plot_fit_delchi().


The get_data_contour command returns a data contour object which holds references to various plot preferences and data arrays. The attributes are:

Field name Description
x0 The coordinate values for the first axis as a 1D array
x1 The coordinate values for the second axis as a 1D array
y The data value at each point of (x0,x1) as a 1D array
levels The levels used for drawing contours
xlabel The label for the X axis
ylabel The label for the Y axis
title The plot title
contour_prefs The preferences for the plot


The get_data_contour_prefs command returns a dictionary of data contour preferences. By default, the set is empty:



The get_data_image command returns an image object which holds the reference to the image array. The attributes are:

Field name Description
name A label for the object
y The image data (as a 2D array)
eqpos Information on the world coordinate system (if available)
sky Information on the physical coordinate system (if available)

Example 1

sherpa> p = get_data_plot_prefs()
sherpa> p["xlog"] = True
sherpa> p["ylog"] = True
sherpa> p["symbolfill"] = True
sherpa> p["symbolstyle"] = chips_diamond
sherpa> p["symbolcolor"] = "blue"
sherpa> p["errcolor"] = "yellow"
sherpa> p["errstyle"] = "capped"
sherpa> p["linetyle"] = chips_solid
sherpa> p["linecolor"] = "orange"
sherpa> p["linethickness"] = 2

Change the defaults for plot_data() so that:

  • both the X and Y axes will be drawn using a log scale;
  • symbols will be drawn as blue, filled diamonds;
  • errors will be drawn as yellow bars with caps on the end;
  • the points will be connected using a solid, orange line of thickness 2.

Example 2

sherpa> d = get_data_plot()
sherpa> erase()
sherpa> add_curve(d.x, d.y, d.yerr)
sherpa> set_plot_xlabel(d.xlabel)
sherpa> set_plot_ylabel(d.ylabel)
sherpa> set_plot_title(d.title)

Manually create a plot of the data, similar to that created by the plot_data() command.

Example 3

sherpa> get_data_contour("src")

Return a data contour object for dataset "src".


See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

get_conf, get_covar, get_int_proj, get_int_unc, get_proj, get_reg_proj, get_reg_unc
copy_data, dataspace1d, dataspace2d, datastack, delete_data, fake, get_areascal, get_arf, get_arf_plot, get_axes, get_backscal, get_bkg, get_bkg_plot, get_bkg_scale, get_coord, get_counts, get_data, get_dep, get_dims, get_error, get_exposure, get_grouping, get_indep, get_quality, get_rmf, get_specresp, get_staterror, get_syserror, group, load_ascii, load_data, load_grouping, load_quality, set_data, set_quality, ungroup, unpack_ascii, unpack_data
get_filter, load_filter, set_filter
calc_stat_info, get_fit, get_stat_info
get_default_id, list_data_ids, list_response_ids, list_stats
get_draws, get_iter_method_name, get_iter_method_opt, get_method
clean, get_model, get_model_component, get_model_component_image, get_model_component_plot, get_model_plot, get_num_par, get_order_plot, get_par, get_pileup_model, get_response, get_source, get_source_component_image, get_source_component_plot, image_source
get_split_plot, plot_data, set_xlinear, set_xlog, set_ylinear, set_ylog
get_kernel, get_psf
save_error, save_filter, save_grouping, save_quality, save_staterror, save_syserror
get_chisqr_plot, get_delchi_plot, get_prior, get_sampler, get_stat
calc_data_sum, calc_data_sum2d, calc_ftest, calc_kcorr, calc_mlr, calc_model_sum2d, calc_source_sum2d, get_analysis, get_rate
contour, contour_data, contour_ratio, get_ratio, get_resid, histogram1d, histogram2d, image_data, image_getregion, rebin

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.