Representing density in two dimensions
I’ll be subbing today for Chris, as we continue to explore some ggplot2 basics. Today, imagine that you have data distributed in two dimensions, and that you would like to convey differences in point density over space.
As with many things, this is fairly easy to do with ggplot2, but it’s not quite as straightforward as it relies on the use of a “stat,” as opposed to a “geom.” In this case, we use stat_density2d (naturally), and encode our statistic of interest (density) into an aesthetic variable by use of ..level.. .
To leave a comment
for the author, please follow the link and comment on his blog: is.R()
offers daily e-mail updates
news and tutorials
on topics such as: visualization (ggplot2
), programming (RStudio
, Web Scraping
) statistics (regression
, time series
) and more...
If you got this far, why not subscribe for updates
from the site? Choose your flavor: e-mail
, or facebook