Re: Horizontal error bars [message #10979 is a reply to message #10784] |
Wed, 28 January 1998 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
I~nigo Garcia wrote:
>
> Hi:
>
> Does anyone out there have any routine to plot error bars in the X axis
> ?
> I need to plot both errors in X and Y, and I don't see the way of doing
> it.
>
> Thanks,
>
> I~nigo.
> --
Here's a simple one (not too fancy, but it does what you ask for,
and you should be able to go along from this peace of code:
The program expects a vector with symmetric error values which must
have the same number of elements as x and y do. The _EXTRA keyword
allows you to pass on every fancy thing that PLOTS can handle
without having to worry about it in the routine. Before overlaying
the error bars, you must plot your data with the PLOT command
(or even better: 1st: plot the axis only with PLOT,...,/NODATA
2nd: overlay the error bars
3rd: overlay the symbols )
Hope this helps,
Martin.
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
pro oploterrxy,x,y,xerr,yerr,psym=psym,_EXTRA=e
xlo = x-xerr
xhi = x+xerr
ylo = y-yerr
yhi = y+yerr
; clipping (not done in plots !)
xlo = xlo > !x.crange(0)
xhi = xhi < !x.crange(1)
ylo = ylo > !y.crange(0)
yhi = yhi < !y.crange(1)
for i=0,n_elements(x)-1 do begin
plots,[xlo(i),xhi(i)],[y(i),y(i)],_EXTRA=e
plots,[x(i),x(i)],[ylo(i),yhi(i)],_EXTRA=e
endfor
return
end
|
|
|