[R] points size in plots
Ruben Roa Ureta
rroa at udec.cl
Fri May 2 23:05:27 CEST 2008
>> -----Original Message-----
>> From: r-help-bounces at r-project.org
>> [mailto:r-help-bounces at r-project.org] On Behalf Of Irene Mantzouni
>> Sent: Friday, May 02, 2008 7:52 AM
>> To: r-help at stat.math.ethz.ch
>> Subject: [R] points size in plots
>>
>> Dear list,
>>
>>
>>
>> I would like to produce a plot of variables where the size of
>> the points will be indicative of their standard errors.
>>
>> How is that possible?
>>
>>
>>
>> Thank you!
Do you mean (a) the larger the standard error, the bigger the point, or
(b) the larger the standard error, the smaller the point? (b) makes more
statistical sense.
Anyways, you can use cex. An example with two variables, u and v, in the
case of (a)
u <- rnorm(10,2,3)
v <- rnorm(10,5,4)
se.u <- runif(10,1,4)
se.v <- runif(10,4,7)
x <- 2:11
plot(x,u,cex=se.u/max(se.u))
points(x,v,cex=se.v/max(se.v),pch=19)
And in the case of (b)
u <- rnorm(10,2,3)
v <- rnorm(10,5,4)
se.u <- runif(10,1,4)
se.v <- runif(10,4,7)
x <- 2:11
plot(x,u,cex=(1/se.u)/max(1/se.u))
points(x,v,cex=(1/se.v)/max(1/se.v),pch=19)
If you have NAs in your variables, use the na.rm=TRUE argument of max().
If the standard errors are very different, you can multiply the quantity
evaluated for cex with a positive constant, say
u <- rnorm(10,2,3)
v <- rnorm(10,5,4)
se.u <- runif(10,1,4)
se.v <- runif(10,4,7)
x <- 2:11
w=2.5
plot(x,u,cex=w*(1/se.u)/max(1/se.u))
points(x,v,cex=w*(1/se.v)/max(1/se.v),pch=19)
HTH
Ruben
More information about the R-help
mailing list