R has a very powerful graphics system, with low-level tools allowing customization of every detail and even setting up the page to show multiple graphics at once, aligning related data in meaningful ways. But the flipside to any powerful system is that it can sometimes be difficult to use, and forces design choices on a user that may prefer to leave the details to the experts.
ggplot2 is an R package for R from Hadley Wickam (Rice University), that simplifies many of the details of creating statistical graphics while using the power of the underlying R graphics system to ensure those graphics are both beautiful and meaningful. For example:
The beauty of the system is that the top-level graphics commands (like qplot in the example above) make sensible and attractive decisions about dimensions, scales, and colors so you don't have to. (Of course, if you want to tinker with those choices, you can customize the graphics in just about any way you want.)
The ggplot2 website contains a host of useful information, including searchable documentation. To see some great examples of ggplot2 in action, browse through the various sections (for example, geom_boxplot) and scroll to the Examples section for a gallery of plots of the specific type with the R code to create them. You'll also find there a link to a draft of the ggplot2 book (to be published in 2009) with many more examples.
To get started with ggplot2, just install the package from CRAN: install.packages("ggplot2")
More information: ggplot2 website.
Thanks for the mention!
Posted by: Hadley Wickham | January 07, 2009 at 09:35
I just spent the holidays reading the ggplot2 book Hadley so kindly provides free online. I'm helping to teach an R course next summer and I've been tasked to cover plotting. ggplot2 will clearly make my life and that of the students far easier than had I tried to teach lattice.
As a cognitive scientist, I also quite like the default use of the HCL color scheme, ensuring that manipulations of hue via the "color" argument aren't confounded with variation in chroma and luminance.
Posted by: Mike | January 07, 2009 at 16:55
What is missing from the otherwise VERY useful chapter "Getting started with qplot" in Hadley Wickham's fine book are two small, but critical, commands for the newbie (like me):
> library(ggplot2)
> data(diamonds)
I had assumed that after I installed the package I was good to go. However, as all of you experienced R guys know these commands are needed to use the qplot() function and the diamonds sample database in each new R session.
Posted by: Owen Dall | November 21, 2010 at 05:25