comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Error Bars in X & Y directions ...
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: error bars [message #3161 is a reply to message #1565] Thu, 24 November 1994 02:22 Go to previous message
sjt is currently offline  sjt
Messages: 72
Registered: November 1993
Member
Vincent E. Kargatis (vek@spacsun.rice.edu) wrote:
: I'm looking for a simple way to make *both* X and Y error bars. The
: USERLIB error bar routines only supply Y error bars (why anyone would think
: that's sufficient I have no idea, grumble grumble). One program I'm using
: draws them by individually connecting each plus & minus value - is there no
: way to do the whole array at once?

: Thanks,
: Vince, who is completely bewildered by the lack of X error bar plotting
: capability in a multitude of packages. Does everyone besides me live in a
: perfect world?

Here is my solution to the problem. The option for capped error bars has
been removed as I didn't need that and it would make the code very messy.

To use the X-error bars, just call with the /HORIZONTAL key specified.
Clearly if you want both X & Y bars you need 2 calls one for the X bars
and one for the Y bars.

++++ CUT HERE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pro hs_errplot, x, low, high, horizontal = horizontal

;+
; HS_ERRPLOT
; Overplot error bars over a previously drawn plot.
;
; CATEGORY:
; J6 - plotting, graphics, one dimensional.
; CALLING SEQUENCE:
; HS_ERRPLOT, Low, High ;X axis = point number
; HS_ERRPLOT, X, Low, High ;to specify abscissae
; INPUTS:
; Low = vector of lower estimates, = to data - error.
; High = upper estimate, = to data + error.
; OPTIONAL INPUT PARAMETERS:
; X = vector containing abscissae.
; KEYWORD Parameters:
; HORIZONTAL if set and non-zero, then plot the error bars || to the
; x-axis
; OUTPUTS:
; None.
; COMMON BLOCKS:
; None.
; SIDE EFFECTS:
; Overplot is produced.
; RESTRICTIONS:
; Logarithmic restriction removed.
; PROCEDURE:
; Error bars are drawn for each element.
; For example: Y = data values, ERR = symmetrical error estimates:
; PLOT,Y ;Plot data
; HS_ERRPLOT, Y-ERR, Y+ERR ;Overplot error bars.
; If error estimates are non-symetrical:
; PLOT,Y
; HS_ERRPLOT, Upper, Lower ;Where upper & lower are bounds.
; To plot versus a vector of abscissae:
; PLOT,X,Y ;Plot data.
; HS_ERRPLOT,X,Y-ERR,Y+ERR ;Overplot error estimates.
; MODIFICATION HISTORY:
; DMS, RSI, June, 1983.
; Joe Zawodney, LASP, Univ of Colo., March, 1986. Removed logarithmic
; restriction.
; DMS, March, 1989. Modified for Unix IDL.
; SJT (U. of Bham). Remove width, add HORIZONTAL. (Mar 1992)
;-

if n_params(0) eq 3 then begin ;X specified?
up = high
down = low
xx = x
endif else begin ;Only 2 params
up = x
down = low
xx=findgen(n_elements(up)) ;make our own x
endelse


n = n_elements(up) < n_elements(down) < n_elements(xx) ;# of pnts
xxmin = min(!x.crange) ;X range
xxmax = max(!x.crange)
yymax = max(!y.crange) ;Y range
yymin = min(!y.crange)

if (!x.type eq 1) then begin ;Logarithmic X
xxmax = 10.^xxmax
xxmin = 10.^xxmin
endif

if (!y.type eq 1) then begin ; Logarithmic Y
yymax = 10.^yymax
yymin = 10.^yymin
endif

if (keyword_set(horizontal)) then begin
down = xxmin > down < xxmax
up = xxmin > up < xxmax
for i=0,n-1 do begin ;do each point.
yyy = xx(i) ;y value
if (yyy ge yymin) and (yyy le yymax) then $
plots, [down(i),up(i)], [yyy,yyy]
endfor
endif else begin
down = yymin > down < yymax
up = yymin > up < yymax
for i=0,n-1 do begin ;do each point.
xxx = xx(i) ;x value
if (xxx ge xxmin) and (xxx le xxmax) then $
plots,[xxx,xxx], [down(i),up(i)]
endfor
endelse

return
end
+++++ CUT HERE ++++++++++++++++++++++++++++++++++++++++++++++
--
+------------------------+---------------------------------- --+---------+
| James Tappin, | School of Physics & Space Research | O__ |
| sjt@xun8.sr.bham.ac.uk | University of Birmingham | -- \/` |
| "If all else fails--read the instructions!" | |
+----------------------------------------------------------- --+---------+
[Message index]
 
Read Message
Read Message
Previous Topic: IDL 3.6.1 under OSF/1 V3.0
Next Topic: IBM setup rpoblems

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 07:01:38 PDT 2025

Total time taken to generate the page: 2.72187 seconds