Skip to content

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

5 messages · David Winsemius, gianni lavaredo, Walmes Zeviani +1 more

#
On May 28, 2012, at 9:55 AM, gianni lavaredo wrote:

            
If you tried lines() usin either sdUP or sdDOWN you saw nothing  
because the ylim was set by default using ony hte information in the  
mean vector.

Try:

 > plot(mydata$mean,
+    type="o",
+    ylab="mean",
+    xlab="class", ylim=range(c(mydata$sdUP, mydata$sdDOWN)))
 > lines(mydata$sdDOWN, col="blue", lty=3)
 > lines(mydata$sdUP, col="blue", lty=3)
#
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: