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

Skip the navigation links
Last modified: December 2008

URL: http://cxc.harvard.edu/chips4.1/add_histogram.py.html
AHELP for ChIPS 4.1

add_histogram

Context: py.chips

Synopsis

Creates a histogram-style figure.

Syntax

add_histogram([ChipsId,] filename [,attributes])
add_histogram([ChipsId,] TABLECrate [,attributes])
add_histogram([ChipsId,] counts [,attributes])
add_histogram([ChipsId,] bins, counts [,attributes])
add_histogram([ChipsId,] bin_low, bin_high, counts [,attributes])
add_histogram([ChipsId,] bin_low, bin_high, counts, yerrs [,attributes])
add_histogram([ChipsId,] bin_low, bin_high, counts, ydown, yup,
[,attributes])

Description

  • ChipsId - an optional ChipsId structure containing values to modify the currency state for the command.
  • TABLECrate/filename - input data, specified as a filename or a TABLECrate ("ahelp crates")
  • counts - an array of values containing the sum of counts for each bin
  • bin_low - array of values indicating the low value of the bin delimiter range. The number of values in the array must equal the number of values in the counts array.
  • bin_high - array of values indicating the high value of the bin delimiter range. The number of values in the array must equal the number of values in the counts array.
  • error_down - array of error down values for each bin. The number of values in the array must equal the number of values in the counts array.
  • error_up - array of error up values for each bin. The number of values in the array must equal the number of values in the counts array.
  • attributes - optional parameters which allow the user to configure window properties though a structure, list, or attribute string.

The add_histogram command creates a histogram-style figure whose attributes are specified by user preferences or in an attribute list. The new histogram becomes current by default; providing a ChipsId overrides the currency state.

If bin_low or bin_high column is set to "None", then the column that is provided is used as the midpoint of the bin.

Note that this command does not do any scientific calculations; it takes the input data as given and creates the figure.

Customizing the Histogram

There are several attributes that control the histogram characteristics. The attributes can be set to the ChIPS defaults, values provided in the add_histogram command, or values from the user's preference file.

The attributes may also be modified with the set_histogram command at any time; see "ahelp set_histogram" and "ahelp setget" for more information.

The attributes associated with histograms are:

Attribute Description Options Default
depth Value indicating the depth of the plot title see the Depth section of "ahelp chipsopt" 100
dropline Boolean indicating whether bin edges are extended to 0 for connected bins on|off on
err.color Color of the curve err bars name or hex; see the Color section of "ahelp chipsopt" default: white in the ChIPS window, black on printout
err.down Histogram y down errors if data provided true/false true
err.style Specifies the error bar style "bar"|"cap" "bar"
err.thickness Specifies the thickness of error bars 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1
err.up Histogram y up errors if data provided true/false true
fill.color Color of the histogram fill name or hex; see the Color section of "ahelp chipsopt" default
fill.opacity Opacity of the histogram fill 0.0:1.0 1.0
fill.style The fill style for the histogram see the Fill Pattern section of "ahelp chipsopt" 0 (no fill)
line.color Color of the curve line name or hex; see the Color section of "ahelp chipsopt" default: white in the ChIPS window, black on printout
line.style The pattern used for the histogram line style see the Line Style section of "ahelp chipsopt" chips_solid
line.thickness Thickness of the histogram line 0.5 to 10.0; see the Thickness section of "ahelp chipsopt" 1
stem stem used for histogram id alphanumeric hst
symbol.angle The angle of rotation for the histogram symbols -360.0:360.0 0.0
symbol.color Color of the histogram symbols name or hex; see the Color section of "ahelp chipsopt" default: white in the ChIPS window, black on printout
symbol.fill Should the histogram symbols be filled or not true/false false
symbol.size Size of the curve symbols 1:100 5
symbol.style The shape of the glyph used as the histogram symbols see the Symbol Styles section of "ahelp chipsopt" chips_none

Example 1

chips> add_histogram("peak.fits[cols energy,counts]")

Create a histogram from energy and counts columns in the file "peak.fits".

Example 2

chips> dat = read_file("peak.fits[cols energy,counts]")
chips> add_histogram(dat)

Create a histogram from energy and counts columns in the file "peak.fits" via CRATES.

Example 3

chips> add_histogram([10,12,15])

A simple add_histogram command, using the default attribute values. This command will divide the x-axis into three equally sized bins; the number of bins is the same as the number of elements in the counts array. The range of the x axis is also equal to the number of bins in the counts array. The center of the x bin ranges are equal to the integer number of bins (i.e. 1.0, 2.0, and 3.0). The Y axis is scaled to the min and max of the counts range array values.

Example 4

chips> add_histogram([1,5,9], [10, 15, 20],["dropline", "on"])

Create three bins of counts of 10, 15 and 20 centered at 1, 5, and 9. The value of dropline is "on", and adjacent bins share borders, so all bin borders are rendered.

Example 5

chips> add_histogram([10, 15, 20], [12, 17, 22], [5,8,13])

Create three bins of counts of 5, 8 and 13. As both the bin_low and bin_high arrays have been given, they are used to specify the actual bin bounds instead of centers.

Example 6

chips> add_histogram([10, 15, 20], [12, 17, 22], [5,8,13], [1,1,2])
chips> set_histogram(["symbol.style", "diamond", "err.style", "capped"])

The previous example is repeated, but symmetric error bars of lengths 1, 1, and 2 have been added. The error style is "bar", and the error bar is centered on the bin.

Example 7

chips> add_histogram([10, 15, 20], [12, 17, 22], [5,8,13], [1,1,2],
[2,4,4])
chips> set_histogram(["symbol.style", "cross", "err.style", "capped"])

The previous example is repeated, but with asymmetric error bars (low values of 1,1,2 and high values of 2,4,4).

CHANGES IN CIAO 4.1

Pattern fill options

The attribute "fill.style" replaces the "fill.visible" attribute. There are multiple fill styles available, instead of a boolean filled/not filled. A value of 0 (chips_nofill) is equivalent to fill.visible=0; a value of 1 (chips_solidfill) is equivalent to fill.visible=1 .

Default color not changing for printing

The histogram and region fill colors when set to default were not being changed from a display foreground color to a postscript foreground color.

Bugs

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

Last modified: December 2008



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.