[R] colour-plot of point intensities?

Matthew Vernon M.C.Vernon at warwick.ac.uk
Tue Dec 14 17:48:13 CET 2010


I've spent a while scrabbling around at this problem, to no avail. I'm
sure there /should/ be a simple answer...

I have a large (14 million rows) data set, with two columns. Each row
contains the number of times an individual moved, and the distance
that individual moved in total. I would like a figure where the colour
indicates the density of points, rather like this one my colleague
produced in Matlab (with an older version of the data):


Sadly, my colleague is away at the moment, so I can't find out what
they did in Matlab. How should I be approaching this problem?
[ideally, I'd like a colour-scale like that, too, but]

My current approach, based on a bit in the back of Crawley's R book,
was to create a new data file where I rounded distance off, and
counted the number of similar rows to give a third column (a count). I
then did:

obs <- read.table("numvsdistscount.dat")
zz <- with(obs,interp(V1,V2,V3))

i) I think doing a rounding step to create the third column (separate
from the plot generation) is unwise
ii) This results in a shaded area less than the full area of the plot
iii) The colour comes out almost uniform

I'd be grateful for any pointers.



Matthew Vernon, Research Fellow
Ecology and Epidemiology Group,
University of Warwick

More information about the R-help mailing list