General knowlage about ggplot2



ggplot2 is a R package dedicated to data visualization. It can greatly improve the quality and aesthetics of your graphics. ggplot2 allows to build and custom almost any type of chart.

geom_ functions


ggplot2 builds charts through layers using geom_ functions :



A set of pre-built themes


It is possible to customize any part of a ggplot2 chart thanks to the theme() function. Here is a glimpse of the available themes. You can click on one of the themes to get a brief overview.



plotly turns your ggplot interactive


Another awesome feature of ggplot2 is its link with the plotly library. It allows to make interactive charts.

library(ggplot2)
library(plotly)
library(gapminder)

p <- gapminder %>%
  filter(year==1977) %>%
  ggplot( aes(gdpPercap, lifeExp, size = pop, color=continent)) +
  geom_point() +
  theme_bw()

ggplotly(p)



Contact

This document is a work by Emma Lafaurie (emma.lafaurie@inserm.fr) for the SBIM (Service de Biostatistique et Information Médicale) at Saint-Louis Hospital in Paris.
Based on the template of Yan Holtz.