Re: [R] points size in plots

From: Ruben Roa Ureta <rroa_at_udec.cl>
Date: Fri, 02 May 2008 17:05:27 -0400 (CLT)

>> -----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



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. Received on Fri 02 May 2008 - 21:41:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 02 May 2008 - 22:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive