Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A piece of R Script used to produce an animated line chart.
library(tidyverse)
library(gganimate)
library(ggthemes)
df <- read_csv("pd.csv") %>%
select(-c("Day")) %>%
rename("Email" = `Email Inbox`,
"RIL" = `Reeder Read it Later`,
"Podcasts" = `Podcasts Episodes`,
"YouTube" = `YouTube Watch Later`) %>%
gather(key = type, value = count, Medium:YouTube, factor_key = TRUE) %>%
na.omit()
plot <- ggplot(data = df,
aes(x = Date,
y = count,
color = type,
group = type)) +
geom_point(aes(group = seq_along(Date)),
size = 2,
alpha = .75) +
geom_line(aes(lty = type),
alpha = .6) +
labs(y = "Items Unfinished",
x = "Date",
title = "99 Days of Decluttering") +
scale_linetype_manual(values = c("Medium" = "solid",
"Pocket" = "solid",
"Email" = "solid",
"RSS" = "solid",
"RIL" = "solid",
"Podcasts" = "solid",
"YouTube" = "solid"),
guide = FALSE) +
# scale_color_manual(values = c("Medium" = "#2E2E2E",
# "Pocket" = "#00857E",
# "Email" = "#DB5642",
# "RSS" = "#669BE8",
# "RIL" = "#5E5A55",
# "Podcasts" = "#F7483A",
# "YouTube" = "#FF0B00"),
# name = "") +
theme_solarized_2(light=TRUE) +
scale_colour_solarized('blue', name = "") +
theme(panel.grid = element_blank(),
text = element_text(size = 16,
family = "Palatino"))
plot
plot +
transition_reveal(along = df$Date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment