Skip to content

Instantly share code, notes, and snippets.

@rexarski
Created June 13, 2020 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rexarski/2b811bcdcb4548dfe757cbd0e86f7290 to your computer and use it in GitHub Desktop.
Save rexarski/2b811bcdcb4548dfe757cbd0e86f7290 to your computer and use it in GitHub Desktop.
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