Last active
July 19, 2022 15:45
-
-
Save ikashnitsky/26f9af1015d0e90682141bda951656d7 to your computer and use it in GitHub Desktop.
Popularity of the @year_progress tweets by the % of the year that they mark – https://twitter.com/ikashnitsky/status/1546012109720506369
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=============================================================================== | |
# 2022-07-09 -- twitter | |
# Year progress twitter | |
# Ilya Kashnitsky, ilya.kashnitsky@gmail.com, @ikashnitsky | |
#=============================================================================== | |
library(tidyverse) | |
library(magrittr) | |
library(lubridate) | |
library(hrbrthemes) | |
library(rtweet) | |
options(scipen = 999) | |
yp <- get_timeline("year_progress", n = 3200) | |
df <- yp %>% | |
transmute( | |
favorite_count, | |
year = created_at %>% year, | |
pct = text %>% str_extract("[0-9]+") %>% as.numeric() | |
) %>% | |
filter(pct %in% 0:100) | |
df %>% | |
ggplot(aes(pct, year, fill = favorite_count))+ | |
geom_tile()+ | |
scale_fill_viridis_b( | |
breaks = c(1e2, 1e3, 1e4, 1e5), | |
labels = c(100, 1000, 10000, 100000), | |
option = "B", trans = "log", | |
guide = guide_colorsteps( | |
direction = "horizontal", title.position = "top", | |
barwidth = 15, barheight = 1 | |
) | |
)+ | |
scale_y_continuous(breaks = 2015:2022)+ | |
scale_x_continuous(position = "top")+ | |
coord_fixed(ratio = 4)+ | |
theme_minimal(base_family = "Atkinson Hyperlegible")+ | |
theme( | |
legend.position = "bottom", | |
panel.grid.minor = element_blank() | |
)+ | |
labs( | |
x = "percent of the year passed", | |
fill = "number of likes", | |
caption = "data: @year_progress / design: @ikashnitsky" | |
)+ | |
annotate( | |
"curve", x = 67, xend = 69, y = 2022, yend = 2019.5, color = "#4a4a4a" | |
)+ | |
annotate( | |
"text", x = 68, y = 2022, hjust = 0, color = "#4a4a4a", | |
label = "most popular: 69%", | |
family = "Atkinson Hyperlegible" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment