From: Jim Lemon Organization: bitwrit software To: Levivier Emilie , r-help@stat.math.ethz.ch Subject: Re: [R] Plot problem ! Levivier Emilie wrote: > Hello, > > Is there a simple way to make a plot with xy coordinates and a z value > which determines the size and the color of point on the plot? This is pretty basic, but may be helpful: > test<-c(2,6,4,7,5,6,8,3,7,2) > plot(test,type="n",main="Color/size test plot",ylab="Size scale",xlab="Color scale") > colsiz<-function (yvec) { ymin <- min(yvec) cexdiv <- max(yvec)/2 for (i in 1:length(yvec)) { nextcex <- (yvec[i] - ymin)/cexdiv + 1 par(cex = nextcex) points(i, yvec[i], type = "p", col = i) } } > colsiz(test) Note that the size here ranges from 1->2. You can change that by fiddling with the calculation of 'cexdiv'. Oops, I just realized that I used the x and y values to determine the color and size, but that may be what you wanted anyway... Jim