pl_submissions_per_bill<- df_consolidated %>%
mutate(bill_indicator=case_when(str_detect(title, "Epidemie") & legis_period=="XXVII" ~ "yes",
TRUE ~ as.character("no"))) %>%
ungroup() %>%
ggplot()+
labs(title="LEGISLATIVE CONSULTATION PROCESS:\nNumber of filed submissions per bill.",
subtitle="Note log scale of y-axis.",
x="Date",
y="Number of submissions (log scale)",
caption=caption)+
geom_segment(aes(x=as.Date("2017-01-01"),
xend=as.Date("2017-01-01"),
y=0,
yend=4000),
color="grey50")+
geom_text(label=str_wrap("Introduction of possibility to file electronic submissions via parliament's website",30),
aes(x=as.Date("2016-06-01"),
y=6000),
color="grey50",
lineheight=0.7,
check_overlap = T,
hjust=1,
vjust=1,
size=3,
family="Roboto condensed")+
geom_jitter_interactive(aes(x=date_end_max,
y=n_obs_submissions,
tooltip=glue::glue("{str_wrap(title, 40)}
Number of submissions: {n_obs_submissions}
Bill ID: {bill_id}/{legis_period},
Click to open submission page"),
onclick=paste0('window.open("', link_single_bill_page, '#tab-Stellungnahmen', '")'),
color=bill_indicator))+
geom_text(label=str_wrap("Epidemiegesetz, COVID-19-Maßnahmengesetz, Änderung (88/ME)
", 40),
aes(x=as.Date("2021-01-01"),
y=19000),
color="firebrick",
lineheight=0.7,
check_overlap = T,
hjust=1,
size=3,
family="Roboto Condensed")+
scale_x_date(breaks=c(seq.Date(as.Date("1990-01-01"), as.Date("2020-01-01"), by="10 year"), as.Date("2017-01-01"),
as.Date(min(df_consolidated$date_end_max))),
date_labels = "%Y" )+
scale_y_log10(labels=scales::label_comma(accuracy=1),
limits=c(1, 20000))+
scale_color_manual(values=c("yes"="firebrick",
"no"="grey50"),
labels=c("yes"="Covid-19 related bills",
"no"="other"))+
guides(color=guide_legend(reverse=T))+
theme_post()+
theme(plot.title.position = "panel",
legend.position = "top",
legend.direction = "horizontal",
legend.justification = "left",
legend.title = element_blank(),
axis.title.x = element_text(hjust=0,
color="grey30"),
axis.title.y=element_text(hjust=0,
color="grey30",
angle=90))
pl_submissions_per_bill <- girafe(ggobj = pl_submissions_per_bill,
height_svg = 5,
options = list(
opts_toolbar(saveaspng = FALSE),
opts_tooltip(css = glue::glue("background-color:{plot_bg_color};
line-height:100%;
color:black;
font-size:80%;
font-family:'Roboto Condensed';)"))
))