
4 Dot plots
4.1 Description
A dot plot displays each data point as a dot on a single axis, making it useful for identifying patterns, gaps, and outliers in small to moderate datasets. Each dot represents an observation in the data, stacked over categories or spread along a number line.
4.2 Set up
PACKAGES:
Install packages.
show/hide
install.packages("palmerpenguins")
library(palmerpenguins) 
library(ggplot2)DATA:

The penguins data
show/hide
penguins <- palmerpenguins::penguins
glimpse(penguins)
#> Rows: 344
#> Columns: 8
#> $ species           <fct> Adelie, Adelie, Adelie…
#> $ island            <fct> Torgersen, Torgersen, …
#> $ bill_length_mm    <dbl> 39.1, 39.5, 40.3, NA, …
#> $ bill_depth_mm     <dbl> 18.7, 17.4, 18.0, NA, …
#> $ flipper_length_mm <int> 181, 186, 195, NA, 193…
#> $ body_mass_g       <int> 3750, 3800, 3250, NA, …
#> $ sex               <fct> male, female, female, …
#> $ year              <int> 2007, 2007, 2007, 2007…::::
4.3 Grammar
CODE:
Create labels with labs()
Initialize the graph with ggplot() and provide data
Map flipper_length_mm to the x axis
Add the geom_dotplot() layer
Adjust the dotsize
show/hide
labs_dotplot <- labs(
  title = "Adult foraging penguins",
  subtitle = "Distribution of flipper length",
  x = "Flipper length (millimeters)")
ggp2_dotplot <- ggplot(data = penguins,
      aes(x = flipper_length_mm)) + 
    geom_dotplot(dotsize = 0.5) 
ggp2_dotplot + 
  labs_dotplotGRAPH:

A downside of using dot plots is the lack of interpretability of the y axis.