-
Notifications
You must be signed in to change notification settings - Fork 1
/
2021_01_12_tidy_tuesday.Rmd
125 lines (96 loc) · 2.99 KB
/
2021_01_12_tidy_tuesday.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
title: 'Tidy Tuesday 01/12'
author: "Lisa Lendway"
output:
html_document:
df_print: paged
code_download: true
theme: cerulean
---
```{r setup, include=FALSE}
# You may want to comment this out at first so you see important messages and warnings
knitr::opts_chunk$set(echo = TRUE, error=TRUE, message=FALSE, warning=FALSE)
```
```{r libraries}
library(tidyverse) # for graphing and data cleaning
library(lubridate) # for date manipulation
library(ggthemes) # for even more plotting themes
library(ggtext) # for adding color to titles
library(gganimate) # for animation
theme_set(theme_minimal()) # My favorite ggplot() theme :)
```
The data this week is are from the Tate Art Museum. Read more details [here](https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-01-12/readme.md).
```{r}
# Read in the data for the week
artwork <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-01-12/artwork.csv')
artists <- readr::read_csv("https://github.com/tategallery/collection/raw/master/artist_data.csv")
```
## within 30 minute
```{r}
artwork %>%
summarize(n_distinct(year))
```
```{r}
art_gganim_start <- artwork %>%
drop_na(width, height) %>%
select(id, year, width, height) %>%
# sample_n(size = 10000) %>%
mutate(left = -width/2,
right = width/2,
top = height/2,
bottom = -height/2) %>%
ggplot(aes(xmin = left,
xmax = right,
ymin = bottom,
ymax = top,
group = id)) +
geom_rect(alpha = 0, color = "gray") +
theme_void() +
transition_manual(year) +
labs(title = "Size of Artwork in Tate Art Museum",
subtitle = "Year: {closest_state}",
caption = "Viz by @lisalendway")
animate(art_gganim_start,
nframes = 370,
duration = 60)
```
## After 30
Made a couple changes
```{r}
year_smry <- artwork %>%
drop_na(width, height) %>%
group_by(year) %>%
summarize(avg_width = mean(width),
avg_height = mean(height)) %>%
mutate(left = -avg_width/2,
right = avg_width/2,
top = avg_height/2,
bottom = -avg_height/2)
art_gganim_start <- artwork %>%
drop_na(width, height) %>%
select(id, year, width, height) %>%
# sample_n(size = 10000) %>%
mutate(left = -width/2,
right = width/2,
top = height/2,
bottom = -height/2) %>%
ggplot(aes(xmin = left,
xmax = right,
ymin = bottom,
ymax = top)) +
geom_rect(aes(group = id),
alpha = 0,
color = "gray") +
geom_rect(data = year_smry,
alpha = 0,
color = "black") +
theme_void() +
transition_manual(year) +
labs(title = "Tate Art Museum size variation",
subtitle = "Year created: {current_frame}",
caption = "Viz by @lisalendway")
animate(art_gganim_start,
nframes = 370,
duration = 30)
anim_save("art_anim.gif", path = "images/")
```