ggplot2
A layered grammer of graphics in R
ggplot2
ggplot2
tidyverse
|>
or %>%
A | B | C |
---|---|---|
1 | 4 | p |
2 | 3 | p |
3 | 2 | q |
4 | 1 | q |
# A tibble: 4 × 3
A B C
<dbl> <dbl> <chr>
1 1 4 p
2 2 3 p
3 3 2 q
4 4 1 q
A | B | C |
---|---|---|
1 | 4 | p |
2 | 3 | p |
3 | 2 | q |
4 | 1 | q |
x | y |
---|---|
1 | 4 |
2 | 3 |
3 | 2 |
4 | 1 |
A | B | C |
---|---|---|
1 | 4 | p |
2 | 3 | p |
3 | 2 | q |
4 | 1 | q |
x | y | shape |
---|---|---|
1 | 4 | p |
2 | 3 | p |
3 | 2 | q |
4 | 1 | q |
Rows: 344
Columns: 8
$ species <fct> Adelie, Adelie, Adelie, Adelie, Adelie, Adelie, Adel…
$ island <fct> Torgersen, Torgersen, Torgersen, Torgersen, Torgerse…
$ bill_length_mm <dbl> 39.1, 39.5, 40.3, NA, 36.7, 39.3, 38.9, 39.2, 34.1, …
$ bill_depth_mm <dbl> 18.7, 17.4, 18.0, NA, 19.3, 20.6, 17.8, 19.6, 18.1, …
$ flipper_length_mm <int> 181, 186, 195, NA, 193, 190, 181, 195, 193, 190, 186…
$ body_mass_g <int> 3750, 3800, 3250, NA, 3450, 3650, 3625, 4675, 3475, …
$ sex <fct> male, female, female, NA, female, male, female, male…
$ year <int> 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007, 2007…
ggplot2
in actionggplot2
Layered grammer of graphics
aesthetic values
aes()
geometric objects
geom_*()
ggplot2
mapping
& aes()
x
y
fill
colour
shape
size
geom_*
geom_point()
geom_line()
geom_bar()
geom_histogram()
geom_boxplot()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
aes()
ggsave()
width
, height
, dpi
, etcggplot2
aes()
geom_*
scale_*
facet_*
theme_*
and theme()
ggplot2
|>
or %>%
with dplyr
verbs first
filter()
mutate()
summarise()
+
ggsave()