Skip to content

Instantly share code, notes, and snippets.

@ColinFay
Last active January 13, 2021 16:22
Show Gist options
  • Save ColinFay/c9ee7a07d9ca55f4ef38b00a531e37c9 to your computer and use it in GitHub Desktop.
Save ColinFay/c9ee7a07d9ca55f4ef38b00a531e37c9 to your computer and use it in GitHub Desktop.
library(tidyverse)
raw_data <- read_csv("https://www.data.gouv.fr/fr/datasets/r/eb672d49-7cc7-4114-a5a1-fa6fd147406b")
df <- raw_data %>%
filter(
date == as.character(
Sys.Date() - 1
)
)
hier <- raw_data %>%
filter(
date == as.character(
Sys.Date() - 2
)
)
df <- raw_data %>%
pivot_wider(
names_from = date,
values_from = total_vaccines
) %>%
mutate(
evol = `2021-01-12` - `2021-01-11`
) %>%
right_join(df)
ggplot(
df,
aes(
nom,
total_vaccines
)
) +
geom_col(
fill = "#599bca"
) +
geom_text(
aes(
label = paste0(
prettyNum(
total_vaccines,
big.mark = " "
),
" (+",
prettyNum(
evol,
big.mark = " "
),
")"
)
),
nudge_y = 3200
) +
coord_flip() +
labs(
title = sprintf(
"Nombre de vaccinations contre la Covid-19 en France, par Région - %s\n\nTotal : %s — Évolution j-1 : + %s",
unique(df$date),
prettyNum(
sum(df$total_vaccines),
big.mark = " "
),
prettyNum(
sum(df$total_vaccines) - sum(hier$total_vaccines),
big.mark = " "
)
),
x = "",
y = "",
caption = "Via 'Données relatives aux personnes vaccinées contre la Covid-19', data.gouv.fr"
) +
theme_minimal() +
theme(
plot.title = element_text(
size = rel(1.75),
margin = margin(20, 20, 20, 20),
hjust = 0
),
plot.subtitle = element_text(
size = rel(2),
#margin = margin(20, 20, 20, 20),
hjust = 0.5
),
plot.caption = element_text(
size = rel(1.5),
margin = margin(20, 20, 20, 20)
),
axis.text = element_text(
size = rel(1.2),
margin = margin(20, 20, 20, 20)
),
plot.margin = margin(30,30,30,30),
text = element_text(family = "Raleway Light" )
) +
ylim(0, 45000)
ggsave(
sprintf(
"%s.png",
unique(df$date)
),
width = 14,
height = 10
)
browseURL(
sprintf(
"%s.png",
unique(df$date)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment