[R] bubble.plot() - standardize size of unit circle

From: Dan Bebber <danbebber_at_yahoo.co.uk>
Date: Thu 21 Jul 2005 - 21:05:45 EST


Hello,

I wrote a wrapper for symbols() that produces a bivariate bubble plot, for use when plot(x,y) hides multiple occurrences of the same x,y combination (e.g. if x,y are integers).
Circle area ~ counts per bin, and circle size is controlled by 'scale'.
Question: how can I automatically make the smallest circle the same size as a standard plot character, rather than having to approximate it using 'scale'?

#Function:

bubble.plot<-function(x,y,scale=0.1,xlab=substitute(x),ylab=substitute(y),...){ z<-table(x,y)

xx<-rep(as.numeric(rownames(z)),ncol(z))
yy<-sort(rep(as.numeric(colnames(z)),nrow(z)))
id<-which(z!=0)

symbols(xx[id],yy[id],inches=F,circles=sqrt(z[id])*scale,xlab=xlab,ylab=ylab,...)}

#Example:

x<-rpois(100,3)
y<-x+rpois(100,2)
bubble.plot(x,y)                 



How much free photo storage do you get? Store your holiday

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 21 21:11:08 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:53 EST