[R] plot xy data with error bars

Sean O'Riordain seanpor at acm.org
Thu May 25 10:05:21 CEST 2006


Hi Petr,

I just needed to add an 'attach/detach' to get it going.

A<-data.frame(x=1:10, y=1:10, erx=rnorm(10)^2, ery=rnorm(10)^2)
attach(A)
plot(x,y)
arrows(x,y,x+erx/10,y, angle=90, length=.1)
arrows(x,y,x-erx/10,y, angle=90, length=.1)
arrows(x,y,x,y-ery/10, angle=90, length=.1)
arrows(x,y,x,y+ery/10, angle=90, length=.1)
detach(A)

cheers and thanks!
Sean


On 25/05/06, Petr Pikal <petr.pikal at precheza.cz> wrote:
> Hi
>
>
> On 25 May 2006 at 1:08, Tibi Codilean wrote:
>
> Date sent:              Thu, 25 May 2006 01:08:20 +0100
> From:                   "Tibi Codilean" <Tibi.Codilean at ges.gla.ac.uk>
> To:                     r-help at stat.math.ethz.ch
> Subject:                [R] plot xy data with error bars
>
> > Dear All,
> >
> > I have x,y data with errors associated with both x and y. What would
> > be the easiest way of creating plots with both x and y error bars?
>
> I know there is some function(s) in some package(s) for error bar
> plotting but if you want to use your own, use arrows
>
> A<-data.frame(x=1:10, y=1:10, erx=rnorm(10)^2, ery=rnorm(10)^2)
> plot(x,y)
> arrows(x,y,x+erx/10,y, angle=90, length=.1)
> arrows(x,y,x-erx/10,y, angle=90, length=.1)
> arrows(x,y,x,y-ery/10, angle=90, length=.1)
> arrows(x,y,x,y+ery/10, angle=90, length=.1)
>
> HTH
> Petr
>
>
> >
>
> >
> > Thanks
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> Petr Pikal
> petr.pikal at precheza.cz
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list