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

Dan Bebber danbebber at yahoo.co.uk
Thu Jul 21 13:05:45 CEST 2005


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




More information about the R-help mailing list