
ggplot2 - Create Elegant Data Visualisations Using the Grammar of …
R for Data Science is designed to give you a comprehensive introduction to the tidyverse, and these two chapters will get you up to speed with the essentials of ggplot2 as quickly as possible.
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
To create your own geoms, stats, scales, and facets, you’ll need to learn a bit about the object oriented system that ggplot2 uses. Start by reading vignette("extending-ggplot2") then consult these functions …
ggplot2: Create Elegant Data Visualisations Using the Grammar of ...
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 takes …
Bar charts — geom_bar • ggplot2
Thus, ggplot2 will by default try to guess which orientation the layer should have. Under rare circumstances, the orientation is ambiguous and guessing may fail. In that case the orientation can …
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 …
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 …
Text — geom_label • ggplot2
If NULL, the default, the data is inherited from the plot data as specified in the call to ggplot(). A data.frame, or other object, will override the plot data.
Construct aesthetic mappings — aes • ggplot2
Aesthetic mappings describe how variables in the data are mapped to visual properties (aesthetics) of geoms. Aesthetic mappings can be set in ggplot() and in individual layers.