[R] colour-plot of point intensities?

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


Hi,

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):

http://www.warwick.ac.uk/~lssgah/warwick1.pdf

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:

library(akima)
obs <- read.table("numvsdistscount.dat")
zz <- with(obs,interp(V1,V2,V3))
filled.contour(zz,col=heat.colors(12))

But:
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.

Thanks,

Matthew

-- 
Matthew Vernon, Research Fellow
Ecology and Epidemiology Group,
University of Warwick
http://blogs.warwick.ac.uk/mcvernon



More information about the R-help mailing list