|
|
|
|
SynopsisCreates a curve. Syntaxadd_curve( [ChipsId,] filename [,attributes]) add_curve( [ChipsId,] TABLECrate [,attributes]) add_curve( [ChipsId,] x, y [,attributes]) add_curve( [ChipsId,] x, y, error_list|None [,attributes]) add_curve( [ChipsId,] x, y, error_list|None, limits_list|None [,attributes]) Description
The add_curve command creates a curve whose attributes are specified by user preferences or in an attribute list. The new curve becomes current by default; providing a ChipsId overrides the currency state. A curve needs a minimum of a pair of numeric data arrays of the same length to plot. If an existing plot is current, the curve is added to that plot. If there is no current plot, one is created and the curve is placed in it. To overplot curves, simply add them all to the same plot object. Up to six additional data columns may be provided as error and limits information. The error and limits information is interpreted based on how many columns are supplied to the command, as described above. On account of this, an entry for the error_list array must be provided in order to include limits data. If no error_list is needed, the value "None" may be used. Customizing the CurveThere are several attributes that control the curve characteristics. The attributes can be set to the ChIPS defaults, values provided in the add_curve command, or values from the user's preference file. The attributes may also be modified with the set_curve command at any time; see "ahelp py.chips set_curve" and "ahelp py.chips setget" for more information. The attributes associated with curves are:
Example 1
chips> add_curve("lc.fits[cols time, count_rate]")Plot the time versus count_rate columns from the FITS file "lc.fits". The Data Model virtual filter syntax "[cols time, count_rate]" is used to select the X and Y columns from the file. Example 2
chips> add_curve("lc.fits[cols time, count_rate]",["line.color","red"])Plot the time versus count_rate columns from the FITS file "lc.fits", and draw the lines between the points in red. Example 3
chips> add_curve("lc.fits[cols time, count_rate, stat_err]")Plot the time versus count_rate columns, and use the stat_err column as symmetric Y errors. Example 4
chips> add_curve("lc.fits[cols time, count_rate,
stat_err]",["line.color", "red", "err.color", "coral", "symbol.style",
"circle", "symbol.size", 6])Repeat the previous example, this time overriding several of the preference settings for curves. Example 5
chips> dat = read_file("lc.fits[cols time, rate, error]")
chips> add_curve(dat)Read in the time, rate, and error columns from a file using the Crates routine read_file, then plot the data. Example 6chips> x = numpy.arange(11) chips> add_curve(x, x*x) Plot the curve y = x^2 for the integer values 0 to 10. Example 7chips> z = numpy.arange(10) chips> add_curve(z,z-4,[z*0.2,z*0.1]) Create a curve with assymetric Y error bars. Example 8
chips> x = numpy.arange(0,10,0.1)
chips> set_preference("curve.symbol.style","none")
chips> add_curve(x,numpy.sin(x),["line.color","plum"])
chips> add_curve(x,numpy.cos(x),["line.color",0xf04539, "line.style",
"dot"])Set the symbol.style preference to "none" before adding the curves. Overplot the cosine curve on top of the sine curve, specifying attributes in a list. Example 9
chips> in = read_file("data.fits")
chips> x = get_colvals(in, "X")
chips> y = get_colvals(in, "Y")
chips> add_curve(x, y)
chips> vals = ChipsCurve()
chips> vals.line.style = "none"
chips> vals.symbol.fill = False
chips> vals.symbol.size = 5
chips> vals.symbol.color = "sienna"
chips> set_curve(vals)Create a curve of the X and Y columns from data.fits. Populate the "vals" structure, then set the curve attributes. BugsSee the bugs pages on the ChIPS website for an up-to-date listing of known bugs. |
![]() |
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. |