[R] Sizeplot Legend

Jim Lemon jim at bitwrit.com.au
Thu May 22 01:49:02 CEST 2014


On Wed, 21 May 2014 06:34:58 PM Liz Duermit wrote:
> I'm using the sizeplot() function from the plotrix package to plot 
binomial
> data in which there are a number of repeated values.
> 
> a portion of my data look like this:
> 
> mortality = c(1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,
> 0, 0, 1, 0, 0, 1, 0, 1, 0)
> ww.max = c(4.0,  5.0,  3.0,  2.0,  2.5,  2.5, 10.0,  9.0,  2.0,  0.5,  4.0,
> 3.0,  5.0,  1.0,  4.0, 2.0,  4.0,  3.0,  2.0,  5.0,  6.0,  3.0,  4.0,  2.0,
> 3.0,  4.0,  4.0,  3.0,  5.0,  7.0)
> 
> I am using the following code for my graph:
> 
> sizeplot(ww.max, mortality, scale=1, pow=.75)
> 
> I would like to add a legend that indicates the relationship between 
size of
> the point and the number of repetitions, any suggestions?

Hi Liz,
This might be suitable, although I am not sure whether the calculation 
of "cex" is correct:

mortality<-c(1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 
 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0)
ww.max<-c(4.0,  5.0,  3.0,  2.0,  2.5,  2.5, 10.0,  
 9.0,  2.0,  0.5,  4.0,  3.0,  5.0,  1.0,  4.0, 2.0,  4.0, 
 3.0,  2.0,  5.0,  6.0,  3.0,  4.0,  2.0, 3.0,  4.0,  4.0,
 3.0,  5.0,  7.0)
# get a nicer plot area
x11(height=4)
sizeplot(ww.max, mortality, scale=1, pow=.75,
 ylim=c(-0.5,1.5),yaxt="n")
axis(2,at=0:1,labels=c("alive","dead"))
points(seq(7,9.5,by=0.5),rep(0.6,6),cex=(1:6)^0.8)
text(seq(7,9.5,by=0.5),0.35,1:6)

Jim



More information about the R-help mailing list