ggplot2 is an enhanced plotting library for R based upon the principles of "The Grammar of Graphics". Use this tag for *on topic* questions that (a) involve `ggplot2` as a critical part of the question &/or expected answer, & (b) are not just about how to use `ggplot2`.

ggplot2 is an actively maintained, open-source chart-drawing library for , written by Hadley Wickham, based upon the principles of "The Grammar of Graphics" by Leland Wilkinson. It can stand as an alternative to R's basic plot and the lattice package.


There are several related packages on CRAN that are based upon, or extend ggplot2's functionality:

  • GGally: Package containing templates for different plots to be combined into a plot matrix, as well as a parallel coordinate plot function
  • ggcolpairs: Combination of ggplot2 plots into a matrix based on data columns
  • ggdendro: Tools for extracting dendrogram and tree diagram plot data for use with ggplot2
  • granovaGG: Graphical analysis of variance using ggplot2
  • nvis: Combination of visualization functions for nuclear data using ggplot2 and ggcolpairs
  • ggmap allows visualization of spatial data and models on top of Google Maps, OpenStreetMaps, Stamen Maps, or CloudMade Maps using ggplot2
  • Finally, the package gridExtra is often useful, as ggplot2 is based upon the grid graphics system.

Code Language (used for syntax highlighting): lang-r