[R] Plot problem !

Jim Lemon bitwrit at ozemail.com.au
Wed Nov 17 12:27:14 CET 1999


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


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list