
ggplot2 - Create Elegant Data Visualisations Using the Grammar of …
ggplot2 is a system for declaratively creating graphics, based on The Grammar of Graphics. You provide the data, tell ggplot2 how to map variables to aesthetics, what graphical primitives to use, and it …
Introduction to ggplot2
ggplot2 is an R package for producing visualizations of data. Unlike many graphics packages, ggplot2 uses a conceptual framework based on the grammar of graphics. This allows you to ‘speak’ a graph …
Create a new ggplot — ggplot • ggplot2
ggplot() initializes a ggplot object. It can be used to declare the input data frame for a graphic and to specify the set of aesthetic mappings for the plot, intended to be common throughout all subsequent …
Package index • ggplot2
All ggplot2 plots begin with a call to ggplot(), supplying default data and aesthetic mappings, specified by aes(). You then add layers, scales, coords and facets with +.
FAQ: Barplots • ggplot2
How can I make a bar plot of group means? Either calculate the group means first and use geom_col() to draw the bars or let ggplot2 calculate the means with stat_summary() with fun = "mean" and geom …
FAQ: Reordering • ggplot2
Bar plots How can I reorder the bars in a bar plot by their value? Change the order of the levels of the factor variable you’re creating the bar plot for in the aes thetic mapping. The forcats package offers a …
FAQ: Axes • ggplot2
By default, ggplot2 expands the scale by 5% on each side for continuous variables and by 0.6 units on each side for discrete variables. To keep the default expansion on top while removing it at the …
Extending ggplot2
You’ll learn how to extend ggplot2 by creating a new stat, geom, or theme. As you read this document, you’ll see many things that will make you scratch your head and wonder why on earth is it designed …
FAQ: Customising - ggplot2
Note that ggplot2 has a variety of complete themes that might already do what you’re hoping to accomplish. For example, if you prefer a more minimal look to your plots, without the grey …
Complete themes — ggtheme • ggplot2
The classic dark-on-light ggplot2 theme. May work better for presentations displayed with a projector. theme_linedraw() A theme with only black lines of various widths on white backgrounds, reminiscent …