[R] densCols: what are the computed densities and how to create a legend

Kate Zinszer kate.zinszer at mail.mcgill.ca
Mon Apr 19 21:21:16 CEST 2010


Hi,

I'm using the densCols function for a scatterplot and cannot figure out 1) how to extract the computed densities, and 2) how to create a legend based that represents the upper and lower ranges of the densities.

For example:

movers.den  <- densCols(move$x, move$y)
table(movers.den)
#08306B #083775 #083B7C #083D7E #3989C1 #3F8FC4 
     28           22           101           25          4               5 
#4392C6 #65AAD3 #69ACD5 #6CAED6 #77B4D8 #98C6DF 
     14            6                  8               4                3       9 
plot(move, col=movers.den, pch=20,ylab="y coordinate movement (meters)",xlab="x coordinate movement (meters)")
abline(h=0, v=0, col = "grey", lty=2)
#legend??

Any help would be appreciated!
Kate


More information about the R-help mailing list