Figures will often carry the weight of your arguments.
# A tibble: 13 × 6
dataset mean_x mean_y sd_x sd_y corr_x_y
<chr> <chr> <chr> <chr> <chr> <chr>
1 away 54.3 47.8 16.8 26.9 -0.1
2 bullseye 54.3 47.8 16.8 26.9 -0.1
3 circle 54.3 47.8 16.8 26.9 -0.1
4 dino 54.3 47.8 16.8 26.9 -0.1
5 dots 54.3 47.8 16.8 26.9 -0.1
6 h_lines 54.3 47.8 16.8 26.9 -0.1
7 high_lines 54.3 47.8 16.8 26.9 -0.1
8 slant_down 54.3 47.8 16.8 26.9 -0.1
9 slant_up 54.3 47.8 16.8 26.9 -0.1
10 star 54.3 47.8 16.8 26.9 -0.1
11 v_lines 54.3 47.8 16.8 26.9 -0.1
12 wide_lines 54.3 47.8 16.8 26.9 -0.1
13 x_shape 54.3 47.8 16.8 26.9 -0.1
What do a heatmap, a pie chart and a line chart have in common?
→ All data visualizations map data values into quantifiable features of the resulting graphic
→ We refer to these features as aesthetics
Mapped Dimensions
Five mapping components:
Layer: What we actually see in the plot. Geometric elements (“geoms”. e.g. points, lines, …) or statistical transformations (“stats”. e.g. counting, binning, fitting a model)
Scales: Convert the values in the data space to values in the aesthetic space
Coordinate system: Usually cartesian, but other are available (e.g. polar)
Facet: Subset displays
Theme: Control finer points of the visualization
Three of which are key components that exist in every plot:
→ Data
→ Mapping
→ Geom
#Preparing the data
library(gapminder)
gm_latest <- gapminder %>%
filter(year == max(year)) %>%
rename(GDPpc = gdpPercap,
LE = lifeExp)
gm_latest
# A tibble: 142 × 6
country continent year LE pop GDPpc
<fct> <fct> <int> <dbl> <int> <dbl>
1 Afghanistan Asia 2007 43.8 31889923 975.
2 Albania Europe 2007 76.4 3600523 5937.
3 Algeria Africa 2007 72.3 33333216 6223.
4 Angola Africa 2007 42.7 12420476 4797.
5 Argentina Americas 2007 75.3 40301927 12779.
6 Australia Oceania 2007 81.2 20434176 34435.
7 Austria Europe 2007 79.8 8199783 36126.
8 Bahrain Asia 2007 75.6 708573 29796.
9 Bangladesh Asia 2007 64.1 150448339 1391.
10 Belgium Europe 2007 79.4 10392226 33693.
# ℹ 132 more rows
mtcars
dataset as an exampleCarlos Matos // ISPUP::R4HEADS(2023)