Skip to content
Prev 295875 / 398503 Next

question how to add Standard Deviation as "Whiskers" in a simple plot

Hello,

The function 'arrows' with angle=90 can do the job.

mydata <-
data.frame(mean=c(0.42,0.41,0.41,0.43,0.45,0.43,0.43,0.42,0.44,0.45,0.45,0.45,0.46,0.43,0.42,0.37,0.44,0.46,0.46,0.39,0.40),
sdUP=c(0.58,0.56,0.55,0.57,0.61,0.55,0.57,0.59,0.61,0.60,0.57,0.60,0.62,0.57,0.59,0.56,0.57,0.61,0.61,0.56,0.54),
sdDOWN=c(0.26,0.26,0.28,0.29,0.30,0.30,0.29,0.26,0.28,0.31,0.34,0.30,0.31,0.30,0.25,0.19,0.31,0.31,0.31,0.22,0.25))

x <- 1:nrow(mydata)
with(mydata, plot(1, type="n", xlim=c(1, nrow(mydata)), 
ylim=c(min(sdDOWN), max(sdUP))))
with(mydata, points(x, mean))
with(mydata, arrows(x, mean, x, sdUP, angle=90, length=0.1))
with(mydata, arrows(x, mean, x, sdDOWN, angle=90, length=0.1))


Hope this helps,

Rui Barradas

Em 28-05-2012 18:24, gianni lavaredo escreveu: