[R] add error bars in a plot

Toby Marthews toby.marthews at ouce.ox.ac.uk
Wed Feb 9 11:14:38 CET 2011


Hi Maria,

Instead of using errbar(), you can use the segments command which may be more flexible. Following the example on p.80 (the errbar command) of http://cran.ma.ic.ac.uk/web/packages/Hmisc/Hmisc.pdf

set.seed(1)
x=1:10
y=x+rnorm(10)
delta=runif(10)


barwidth=0.015
x11();plot(x,y)
segments(x,y-delta,x,y+delta)
segments(x-barwidth,y+delta,x+barwidth,y+delta)
segments(x-barwidth,y-delta,x+barwidth,y-delta)

Best,
Toby

________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Gerrit Eichner [Gerrit.Eichner at math.uni-giessen.de]
Sent: 09 February 2011 07:45
To: Lathouri, Maria
Cc: r-help at r-project.org
Subject: Re: [R] add error bars in a plot

Hello, Maria,

take a look at

?errbar

in the package Hmisc.


Hth  -- Gerrit


> Dear all
>
> I have a dataset of how metal concentrations change through time. I have
> made a plot of date versus metal concentration. However I want to add
> error bars in the plot.
>
> Could you help me?
>
> Thanks
> Maria

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list