date | mean temp |
---|---|
2016-01-01 | 24 |
2016-01-02 | 23 |
2016-01-03 | 23 |
2016-01-04 | 17 |
2016-01-05 | 29 |
2016-01-06 | 33 |
2016-01-07 | 30 |
2016-01-08 | 25 |
2016-01-09 | 9 |
2016-01-10 | 11 |
2025-01-13
Mean temperatures in Lincoln, NE, in January 2016:
date | mean temp |
---|---|
2016-01-01 | 24 |
2016-01-02 | 23 |
2016-01-03 | 23 |
2016-01-04 | 17 |
2016-01-05 | 29 |
2016-01-06 | 33 |
2016-01-07 | 30 |
2016-01-08 | 25 |
2016-01-09 | 9 |
2016-01-10 | 11 |
How can we compare distributions across months?
A boxplot is a crude way of visualizing a distribution.
A violin plot is a density plot rotated 90 degrees and then mirrored.
Advantage: Can see raw data points instead of abstract representation.
Horizontal jittering may be necessary to avoid overlapping points.
Advantage: Can see raw data points instead of abstract representation.
Horizontal jittering may be necessary to avoid overlapping points.
Advantage: Can see raw data points instead of abstract representation.
Horizontal jittering may be necessary to avoid overlapping points.
Such plots are called sina plots, to honor Sina Hadi Sohi.
How about we stagger the densities vertically?
Notice the single fill color. More colors would be distracting.
All examples will use the lincoln_temps
dataset:
lincoln_temps <- readRDS(url("https://wilkelab.org/SDS366/datasets/lincoln_temps.rds"))
lincoln_temps
# A tibble: 366 × 4
date month month_long mean_temp
<date> <fct> <fct> <int>
1 2016-01-01 Jan January 24
2 2016-01-02 Jan January 23
3 2016-01-03 Jan January 23
4 2016-01-04 Jan January 17
5 2016-01-05 Jan January 29
6 2016-01-06 Jan January 33
7 2016-01-07 Jan January 30
8 2016-01-08 Jan January 25
9 2016-01-09 Jan January 9
10 2016-01-10 Jan January 11
# ℹ 356 more rows
Plot type | Geom | Notes |
---|---|---|
boxplot | geom_boxplot() |
|
violin plot | geom_violin() |
|
strip chart | geom_point() |
Jittering requires position_jitter() |
sina plot | geom_sina() |
From package ggforce |
ridgeline | geom_density_ridges() |
From package ggridges |
geom_boxplot()
, geom_violin()
, position_jitter()
geom_sina()
geom_density_ridges()