PRO PLOT_HISTO,ARRAY,STEPS,HISTO,XLOG=XLOG,YLOG=YLOG,DELTA=DELTA, $ BCOLOR=BCOLOR,_EXTRA=_EXTRA ;+ ; Project : SOHO - CDS ; ; Name : PLOT_HISTO ; ; Purpose : Plots a histogram from the variable ARRAY. ; ; Category : Class3, Graphics ; ; Explanation : Plots a histogram from the variable ARRAY. Calls FORM_HISTO to ; decide what the coarseness of the histogram should be. Then ; PLOTBAR is called to plot the histogram. ; ; Syntax : PLOT_HISTO, ARRAY [, STEPS, HISTO ] ; ; Examples : ; ; Inputs : ARRAY = Array to plot histogram of. ; ; Opt. Inputs : None. ; ; Outputs : None. ; ; Opt. Outputs: STEPS = Values at which histogram is taken. Each value ; represents histogram between STEP(I) and STEP(I+1). ; HISTO = Histogram values. ; ; Keywords : DELTA = Distance between histogram steps. If not passed, ; then FORM_HISTO chooses a suitable value. ; XLOG = If set, then X axis is logarithmic. ; YLOG = If set, then Y axis is logarithmic. ; BCOLOR = Color to use instead of !BCOLOR for bar interiors. ; ; Calls : FORM_HISTO, PLOTBAR ; ; Common : None. ; ; Restrictions: None. ; ; Side effects: None. ; ; Prev. Hist. : ; William Thompson Applied Research Corporation ; September, 1987 8201 Corporate Drive ; Landover, MD 20785 ; ; William Thompson, December 1991, added keywords XTYPE and YTYPE. ; William Thompson, May 1992, added keywords XRANGE and YRANGE. ; ; History : Version 1, 22-Jan-1996, William Thompson, GSFC ; Incorporated into CDS library ; Version 2, 22-May-2000, William Thompson, GSFC ; Replaced several keywords with _EXTRA mechanism. ; Renamed XTYPE, YTYPE with more modern XLOG, YLOG ; Corrected handling of logarithmic axes. ; ; Contact : WTHOMPSON ;- ; ON_ERROR,2 ; ; Check the input parameters. ; IF N_PARAMS(0) EQ 0 THEN BEGIN MESSAGE = 'Syntax: PLOT_HISTO, ARRAY [, STEPS, HISTO ]' GOTO, HANDLE_ERROR ENDIF IF N_ELEMENTS(ARRAY) LE 2 THEN BEGIN MESSAGE = ' Not enough points to form histogram.' GOTO, HANDLE_ERROR ENDIF ; ; Check to see if a histogram is warranted. ; BANG_C = !C A_MAX = 1.*MAX(ARRAY) A_MIN = 1.*MIN(ARRAY) !C = BANG_C IF A_MAX EQ A_MIN THEN BEGIN MESSAGE = 'No histogram generated--all array elements equal to ' +$ STRTRIM(A_MAX,2) GOTO, HANDLE_ERROR ENDIF IF (A_MAX - A_MIN) LT (1E-4 * ABS(A_MIN)) THEN BEGIN MESSAGE = 'No histogram generated--data range ' + STRING(A_MIN) + $ ' to ' + STRING(A_MAX) + ' too narrow.' GOTO, HANDLE_ERROR ENDIF ; ; Call FORM_HISTO to form the histogram, and PLOTBAR to plot it. ; FORM_HISTO,ARRAY,STEPS,HISTO,DELTA=DELTA IF KEYWORD_SET(YLOG) THEN YY = HISTO > 0.1 ELSE YY = HISTO PLOTBAR,STEPS,YY,XLOG=XLOG,YLOG=YLOG,BCOLOR=BCOLOR,_EXTRA=_EXTRA RETURN ; ; Error handling point. ; HANDLE_ERROR: MESSAGE, MESSAGE, /CONTINUE RETURN END