## How do I plot a histogram from a file?

The make_figure and add_histogram commands can plot data from a file (in both FITS binary and ASCII formats). The numpy histogram() command can be used to create a histogram of a column of data for display with add_histogram.

1. Two columns: A set of (xmid,y) points.

make_figure("file.lis[cols x,y]","histogram")


This will plot up columns x and y from the file file.lis, and use x as the middle of each bin.

2. Two columns: A set of ([xlo,xhi],y) points.

make_figure("file.fits[cols r,sur_bri]","histogram")


If the first column selected - here r - is a vector column with two values per row, then these two values will be used as the low and high bounds of each bin. An example of this case is when dmextract has been used to create a radial profile; the R column contains the inner and outer edges of each annulus and so can be used to define the histogram bins.

3. One column: A set of points to histogram.

If you have a set of points which you want to "bin up" to create a histogram then you have to read them in and then use the histogram command from numpy to create the values for use with add_histogram. For example:

cr = read_file("asol1.fits")
ra = copy_colvals(cr, "ra")
(counts, edges) = np.histogram(ra, bins=100)
xlo = edges[:-1]
xhi = edges[1:]

chips> help np.histogram