-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharli.R
73 lines (60 loc) · 2.09 KB
/
charli.R
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
## Charli exploration
library(spotifyr)
# library(ggjoy) ## deprecated
library(ggridges)
library(tidyverse)
library(knitr)
library(ggcute)
# library(extrafont)
# extrafont::font_import()
# extrafont::loadfonts(device = "win")
windowsFonts("Courier" = windowsFont("Courier New"))
## Set working directory
wd <- dirname(rstudioapi::getSourceEditorContext()$path)
setwd(wd)
## Read in
charli <- readRDS(file = "data/charli.rds")
## Order Albums by year released
charli <- mutate(charli, album_name = reorder(charli$album_name, charli$album_release_year))
## Go time
cont_var <- c("danceability", "energy", "speechiness",
"acousticness", "instrumentalness", "liveness", "valence")
## Polar plots
charli %>%
reshape2::melt(measure.var = cont_var) %>%
filter(track_name == "Silver Cross") %>%
ggplot(aes(x = variable, y = value, group = 1, fill = track_name)) +
geom_polygon(show.legend = F) +
coord_polar() +
theme_sugarpill() +
scale_fill_sugarpill() +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
labs(x = "", y = "") +
ggtitle("Silver Cross")
## I do not like SUCKER (delete album please)
ggplot(charli, aes(x = valence, y = album_name, fill = album_name)) +
geom_density_ridges(show.legend = F) +
scale_fill_fairyfloss() +
theme_fairyfloss() +
labs(y = "Album Name")
charli %>%
reshape2::melt(measure.var = cont_var) %>%
ggplot(aes(x = variable, y = value, group = track_name)) +
geom_polygon(show.legend = F, fill = NA, colour = "hotpink") +
coord_polar() +
theme_minimal() +
theme(axis.text.y = element_blank()) +
labs(x = "", y = "") +
facet_wrap(vars(album_name))
charli %>%
reshape2::melt(measure.var = cont_var) %>%
ggplot(aes(x = variable, y = value, group = track_name, colour = "1")) +
geom_polygon(show.legend = F, fill = NA) +
coord_polar() +
theme_sugarpill() +
scale_color_sugarpill() +
theme(axis.text.y = element_blank(),
axis.ticks.y = element_blank()) +
labs(x = "", y = "") +
facet_wrap(vars(album_name))