This is a short post about graphs with lots of data. If you’re going to make a scatter plot, and there are lots of overlapping points use the alpha channel. The alpha channel allows you to add the appearance of transparency to your plotting objects in R, meaning plots with multiple overlapping objects are resolved a little bit better.
It is really easy and it allows you to provide more information than just using a black dot.
plot(x, y, pch=19, col=rgb(0.1, 0.1, 0.1, 0.1))
That’s all there is to it. It makes a plot like this:
Look like this:
Notice how much more information that added. The first plot presents the assumption that there is uniform climate density in the heavily shaded region, but the second plot shows that there is spatial structure even in regions that have dense coverage of the climate space. Some of the ‘climate threads’ are also visible. I’m not really sure what they are, but I assume they’re artifacts of the interpolation process that derives the point based estimates of climate from regional weather stations.
Incidentally, I’ve started to use Hadley Wickham‘s plyr library. Two things that make it great, (1) the ability to have a text progress bar going while you’re running a slow aaply function, (2) the fact that aaply on a sort doesn’t rotate your matrix. I mean, what the heck apply?! Of course, if you had read the help page for apply you’d know why, but nevertheless it always catches me by surprise.
Music for today: Ian and Sylvia Tyson – Early Morning Rain I was really looking for the song ‘Wild Windy Weather’ which I think is really great, Ian Tyson’s got this vocal melody that plays counter to a really solid bass line, but this is pretty good too. I’ve got a soft spot for Ian and Sylvia.