PLOT_HISTOGRAM Procedure
Plots a histogram.
Usage
PLOT_HISTOGRAM, variable
Input Parameters
variable — A 1D array containing histogram data. The array cannot be of type complex, string, or structure.
Keywords
Axiscolor — (integer) Specifies the index of the axis color.
Binsize — Specifies the width of the bins displayed in the histogram.
Fillcolor — (integer) Specifies the index of the color used to fill the histogram.
Filled — If present and nonzero, the histogram is filled with color.
Noaxis — If present and nonzero, no axes are drawn.
NoMinor — If set and nonzero, X axis minor tick marks are suppressed.
Stepped — If present and nonzero, the histogram is plotted as “steps” rather than as “bars”.
Title — A string containing a title for the histogram plot.
Xmax — The maximum value for which histogram data is plotted. Any data that falls above this value will be clipped.
Xmin — The minimum value for which histogram data is plotted. This corresponds to the leftmost point on the x-axis where the plot begins. By default, this minimum is set to zero. If there are negative values in your histogram data, you may need to adjust this value to shift the data to the left. Otherwise, the plot will start at the origin.
Xverts — 1D array containing the x-vertices of the bottom of each bar in the histogram plot is returned. Two paired-elements are returned for each bar.
Additional Keywords
Additional keywords let you control many aspects of a plot’s appearance. Valid keywords for the PLOT_HISTOGRAM procedure are listed below. For a description of each keyword, see Chapter 21: Graphics and Plotting Keywords.
 
Discussion
A histogram is a graph that allows you to visualize quantitative trends in large amounts of data. Histograms are different from bar charts because each “bar” in a histogram represents the results of a statistical sampling of the data, whereas each bar in a bar chart represents a discrete data element. In a histogram, data points do not map to “bars” on the graph one-to-one as they do in a bar chart.
Each “bar” in a histogram is called a bin and the width of each bin represents a range in the independent variable’s values. The height of each bin represents the number of data points in the original variable that fall within the bin width — that is, that fall within the specified range of the independent variable.
This routine is used to render the graphics for the WzHistogram VDA Tool.
Data suitable for use as input to this procedure can be produced with the HISTOGRAM function. For example:
hist_data = HISTOGRAM(original_data)
PLOT_HISTOGRAM, hist_data
The vertices for the eighth bar in a graph (b=8), can be obtained by using the following values returned by the Xverts keyword:
Xverts(i) and Xverts(i+1), where i = b*2
Example
Define a data set and display it to easily see what is expected in each bin.
a = [1, 3, 2, 1, 4, 1, 1, 2, 3]
; Sort the data in array a. You get the following:
; 1       1       1       1       2       2       3       3       4
PM, a(SORT(a))
;  Set binsize, in this example it is set to same as default.
binsize = 1
;  Calculate the ranges for your X axis.
r = [MIN(a, Max=b), b+2*binsize]
;  Calculate the density function of the array.
h= HISTOGRAM(a, Binsize=binsize)
;  Plot your graph.
PLOT_HISTOGRAM, h, Xrange=r, Xmin=r(0), Xmax=r(1), $
   Xtitle='X is in a bin {left,right} if and only if ' + $
   'left <= x < right', Ytitle='Number of values in each bin', $
   Title='PLOT_HISTOGRAM EXAMPLE', $
   Xstyle=1, Yrange=[0, MAX(h)+1], /Ystyle
See Also