; ; $Id: ploterr.pro,v 1.2 1997/12/19 18:57:33 landers Exp $ ; PRO C_PLOTERR,X,Y,ERR, psym = PSYM, type = TYPE, color = COLOR, background = BACKGROUND ; ;+ ; NAME: ; PLOTERR ; PURPOSE: ; Plot data points with accompanying error bars. ; CATEGORY: ; CALLING SEQUENCE: ; PLOTERR, [ X ,] Y , ERR [, PSYM = psym] [, TYPE = type] ; INPUTS: ; X = array of abcissae. ; Y = array of Y values. ; ERR = array of error bar values. ; OPTIONAL INPUT KEYWORD PARAMETERS: ; PSYM = plotting symbol (default = +7) ; ITYPE = type of plot produced. The possible types are: ; ITYPE = 0 : X Linear - Y Linear (default) ; ITYPE = 1 : X Linear - Y Log ; ITYPE = 2 : X Log - Y Linear ; ITYPE = 3 : X Log - Y Log ; COLOR = line color ; BACKGROUND = background color ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; None. ; RESTRICTIONS: ; Arrays must not be of type string. There must be enough points to ; plot. ; PROCEDURE: ; A plot of X versus Y with error bars drawn from Y - ERR to Y + ERR ; is written to the output device. ; MODIFICATION HISTORY: ; William Thompson Applied Research Corporation ; July, 1986 8201 Corporate Drive ; Landover, MD 20785 ; DMS, April, 1989 Modified for Unix ; YA, September, 2003 Added Color and Background keyword ;- ; ; Interpret the input parameters. ; if n_elements(type) eq 0 then type = 0 if n_elements(psym) eq 0 then psym = 7 ; Added by VNIJ 09/25/03***** IF N_ELEMENTS(color) EQ 0 THEN color = !p.color IF N_ELEMENTS(background) EQ 0 THEN background = !p.background ;***************************** ON_ERROR,2 NP = N_PARAMS(0) IF NP LT 2 THEN BEGIN message,'ploterr.usage',/Lookup RETURN ENDIF ELSE IF NP EQ 2 THEN BEGIN ;Only Y and ERR passed. YERR = ABS(Y) YY = X XX = INDGEN(N_ELEMENTS(YY)) ENDIF ELSE BEGIN YERR = ABS(ERR) YY = Y XX = X ENDELSE ; N = N_ELEMENTS(XX) < N_ELEMENTS(YY) < N_ELEMENTS(YERR) IF N LT 2 THEN message, 'ploterr.no_points', /Lookup XX = XX(0:N-1) YY = YY(0:N-1) YERR = YERR(0:N-1) YLO = yy - yerr YHI = yy + yerr ; Set yrange if not already set if !y.range(0) eq !y.range(1) then $ ;yrange specified? yrange = [ min(ylo), max(yhi) ] $ else yrange = !y.range ; ;plot,xx,yy,xtype = type/2, ytype = type and 1, yrange = yrange, psym=psym ;**Modified by VNIJ 09/25/03***** PLOT,xx,yy,xtype = type/2, ytype = type and 1, yrange = yrange, psym=psym, $ Background = background, Color = color ;***************************** ; ; Plot the error bars. ; ;FOR I = 0,N-1 DO plots,[xx(i),xx(i)], [ylo(i), yhi(i)] ;**Modified by VNIJ 09/25/03******** FOR I = 0,N-1 DO PLOTS,[xx(i),xx(i)], [ylo(i), yhi(i)], Color = color RETURN END