The Hitchhiker’s Guide to Ggplot2 in R

[This article was first published on Reimagined Invention, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

About the book

This is a technical book. The scope of the book is to go straight to the point and the writing style is similar to a recipe with detailed instructions. It is assumed that you know the basics of R and that you want to learn how to create beautiful plots.

Each chapter will explain how to create a different type of plot, and will take you step-by-step from a basic plot to a highly customised graph. The chapters’ order is by degree of difficulty.

Every chapter is independent from the others. You can read the whole book or go to a section of interest and we are sure that it will be easy to understand the instructions and reproduce our examples without reading the first chapters.

In total this book contains 218 pages (letter paper size) of different recipes to obtain an acceptable aesthetic result. You can download the book for free (yes, really!) from Leanpub.

Table of contents

  • Chapter 1: Line plots
  • Chapter 2: Area plots
  • Chapter 3: Bar pots
  • Chapter 4: Stacked bar plots
  • Chapter 5: Scatteplots
  • Chapter 6: Weighted scatterplots
  • Chapter 7: Histograms
  • Chapter 8: Density plots
  • Chapter 9: Function plots
  • Chapter 10: Boxplots
  • Chapter 11: Linear regression plots
  • Chapter 12: LOWESS plots

We also included a pack that contains the Rmd files that we used to generate every chart that is displayed in the book.

How the book started?

A few months ago I finished writing the eleventh tutorial in a series on using ggplot2 I created with Jodie Burchell. Jodie holds a PhD, now she’s in the industry and she loves data. I highly recommend reading her blog Standard Error where you can find really good material on Reproducible Research among other things.

A few weeks later those tutorials evolved into the shape of an ebook. The reason behind it was that what we started to write had an unexpected success, and we even had RTs from important people in the R community such as Hadley Wickham. Finally the book was released by Leanpub.

About me, I asked Jodie to co-write a blog entry when I found her blog and I realised that my interest in Data Science/科学数据专业化 and R Programming/R 编程语言 was reflected on her blog.

Why Leanpub?

Leanpub is a platform where you can easily write your book by using MS Word among other writing software and it even has GitHub and Dropbox integration. We went for R Markdown with LaTeX output, and that means that Leanpub is both easy to use and flexible at the same time.

Even more, Leanpub enables the audience to download your books for free, if you allow it, or you can define a price range with a suggested price indication. The website gives the authors a royalty of 90% minus 50 cents per sale (compared to other platforms this is convenient for the authors). You can also sell your books with additional exercises, lessons in video, etc.

Just two weeks ago I updated all the examples contained in my book just a few days after ggplot2 2.2.0 was released and my readers had a notification email just after I uploaded the new version. People who pays or does not pay for your books can download the newer versions of if for free.

What I learned from my first book?

At the moment I am teaching Data Visualization and from my students I learned that good visualizations come after they learn the visualization concepts. Coding cleary helps but coding goes after the fundamentals. It would be better to teach the fundamentals first and not in parallel with coding, and this applies specially when your audience has never wrote code before.

The interested reader may find some remarkable books that can be read before mine. I highly recommend:

Those are really good books that show the fundamentals of Data Visualisation and provide the key concepts and rules needed to communicate effectively with data.

To leave a comment for the author, please follow the link and comment on their blog: Reimagined Invention. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)