Introduction to ggplot
Numeric data
Categorical data
Lets us control:
Every data graphic that you make with ggplot2 will contain at least the following elements:
a call to the ggplot() function that contains:
a data argument that specifies the name of the object containing the data to be plotted
a mapping argument that specifies one (or more) connections between variables in the data frame and elements on the plot
a + operator that adds a new layer to a plot
a call to a geom_*() function that specifies what you actually want to draw
# A tibble: 6 × 3
a b c
<dbl> <dbl> <chr>
1 -2 -0.2 inside
2 -1.9 -1.8 outside
3 -1.8 -3.1 inside
4 -1.5 -3.2 inside
5 -1.4 1.2 outside
6 -1.3 -1.2 inside
Define dataset
Set up variable mapping of one variable on the x-axis of the plot space
Set up variable mapping for two variables, x and y axis of the plot space
Specify the geom type
Color points based on variable in dataset
Color all points the same color
Add a plot title