If you’re ever fumbling around with data in R, you’re probably familiar with the built-in, unattractive graphics. ggplot2’s been increasingly recognized as a necessity for getting the most out of your imagery. It offers nearly complete control over your graphics output, building them layer by layer.
I spent a solid year learning and exploring R as a graduate student before I cracked open Winston Chang’s R Graphics Cookbook and started learning ggplot2’s little oddities. ggplot2 is itself almost like another language within R, but it’s thankfully a very simple language — far more simple and far more flexible, I feel, than the built-in graphics options.
Since you’ll be printing your graphics step by step — your boundaries before your lines; your lines separately from points; etc. — it’s easy to keep track of where every impact on the output image is occurring, allowing you to easily tweak the code and get immediate results. E.g., if annotations are not lining up where you want, or font size needs to be reduced.
Chang’s cookbook is separated by what feature you need to either edit or create, making it easy to jump to what the reader needs. Full sections are devoted to bar graphs, line graphs, scatter plots, data distribution graphics, customizing annotations, axes, legends, color options, and cetera. Nearly 400 pages of text and images showing different ways of customizing and displaying every piece of your graphics. It’s not a book you read cover to cover — just the resource that ‘cookbook’ implies, meeting the reader’s specific needs.
If you want to just jump into the code and see what you can do with your own data, there’s no better place to start. Almost no time is devoted to unnecessary exercises or teaching you the fundamentals of the R programming language. Exploring the far reaches of the Internet is a free alternative that’s likely just as helpful, but Chang’s book serves as a great reference, and contains almost everything you need all in one.
Please see my thesis research page for further examples of graphics built using ggplot2 and Chang’s cookbook.
EDIT 04/2018: Two years after creating these demo graphics here, my imagery has improved so much I’m embarrassed by the stuff here. (One of the quickest fixes for better-looking graphics is using
theme_bw or similar in place of the ggplot themes.) Still, this book helped me figure out the ropes and the language fast, and I still reference my gross, coffee-stained, weird-melted-plastic-goo-covered copy in conjunction with turning to Google.