Plotting data and distribution simultaneously (with ggplot2)
Ever wanted to see at a glance the distribution of your data across different axes? It happens often to me, and R allows to build a nice plot composition – This is my latest concoction. I used ggplot2 here, but equivalent graphics can be made using either base graphics, or lattice.
The set is the usual ‘iris’, the central plot has petal length and width along the X/Y axes – I used a customised color palette so as to be friendlier to color-blind people. On the left and at the top of the main plot, the density distribution of the whole set (grey) and by subspecies.
Well, I hope the code is clear – this time I commented it a bit more…
To leave a comment
for the author, please follow the link and comment on his blog: gRaphics!
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