About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: 9 July 2009

URL: http://cxc.harvard.edu/chips4.1/gallery/errors.sl.html

Gallery: Error bars (S-Lang)

Examples


Symmetric Y errors

Curves and histograms can display error bars; if given a single value, as in this example, then symmetric Y errors are assumed.

[ChIPS output]
Postscript version
variable crv = ChipsCurve;
crv.line.style = "noline";
add_curve("spectrum.fits[residuals][cols x,y,dylo]",crv);
set_curve({"symbol.style","circle","symbol.size",3.0,"symbol.color","red"});
log_scale(X_AXIS);

The error bars can be drawn in a different color to the curve: the available properties of error bars for curves can be seen by saying:

chips> print (get_curve.err);
color = default
down = True
left = False
right = False
style = line
thickness = 1.0
up = True

Errors for both the X and Y axes

Here we display error bars for both the X and Y axes and show how to change the error style so that the errors are drawn with a bar or cap at the end.

[ChIPS output]
Postscript version
variable tbl = read_file("spectrum.fits[residuals]");
variable x = copy_colvals(tbl,"x");
variable y = copy_colvals(tbl,"y");
variable dylo = copy_colvals(tbl,"dylo");
variable dyhi = copy_colvals(tbl,"dyhi");
variable dxlo = copy_colvals(tbl,"dxlo");
variable dxhi = copy_colvals(tbl,"dxhi");
add_curve(x,y,{dylo,dyhi,dxlo,dxhi});
variable crv = ChipsCurve;
crv.line.style = "noline";
crv.symbol.style = "none";
crv.err.style = "capped";
set_curve(crv);
limits(X_AXIS,3.0,AUTO);

In order to display X errors, then four error arrays must be given; one each for the lower and upper errors for the Y and then X axes, even if the errors are symmetrical. The only way this data can be specified is by reading in the data into arrays and then using them in the add_curve call; the following command will not create the same plot:

add_curve("spectrum.fits[residuals][cols x,y,dylo,dyhi,dxlo,dxhi]");

Changes in CIAO 4.1


A histogram with errors and symbols

Histograms can also display error bars, but only for the Y axis.

[ChIPS output]
Postscript version
variable tbl = read_file("histogram.fits");
variable xlo = copy_colvals(tbl,"xlo");
variable xhi = copy_colvals(tbl,"xhi");
variable y = copy_colvals(tbl,"y");
variable dylo = copy_colvals(tbl,"dylo");
variable dyhi = copy_colvals(tbl,"dyhi");
add_histogram(xlo,xhi,y,dylo,dyhi);
set_histogram({"symbol.style","circle","symbol.size",3.0,"symbol.fill",0});

Changes in CIAO 4.1

Last modified: 9 July 2009


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