Monday, February 17, 2014

ggplot2: Cheatsheet for Visualizing Distributions


8 comments:

  1. Wow, Slawa this is a great resource! Thanks so much for putting this together.

    Also I think 3rd plot under 'Boxplots' is a not a volcano plot, but "violin plot":
    http://en.wikipedia.org/wiki/Violin_plot

    Great stuff.

    ReplyDelete
    Replies
    1. Thanks! Thanks for the comment; I changed it.

      Delete
  2. You should check out beanplots, which are basically violin plots, with superimposed boxplots and dot plots. There is a beanplot package for R, but ggplot2 does not include a geom specifically for this. You can easily create one by using geom_violin, geom_boxplot, and geom_point.

    ReplyDelete
    Replies
    1. Yes, I think that's really the beauty of ggplot2 and what I've tried to convey over three posts about it is the idea of layering. You can superimpose layers of points, boxplots, and whatever else you want very easily once you know how to build the different components.

      Delete
  3. > "It's really nice that grid.arrange() clips the plots together so that the scales are automatically the same. "

    That's not the case, and for this very reason I wouldn't recommend using grid.arrange when the axes ought to be aligned. Consider using gtable instead, e.g http://stackoverflow.com/a/21531303/471093

    ReplyDelete
  4. Such a great post, Slawa!
    Tips for the readers - if you are interested in customizing your graphs in ggplot, checkout this blog post in R bloggers - http://www.r-bloggers.com/how-to-customize-ggplot2-graphics/

    ReplyDelete