# Visualizing difference between happiness scores in 2019 and 2020
plot_2020 <- ggplot() +
geom_dumbbell(data = df_2019_2020 %>% filter(diff >0),
aes(y=region, x=happiness_2019, xend=happiness_2020),
size=1.5, color="#7FB185",
colour_xend = "#7FB185", colour_x = "#7FB185",
size_x = 2.5, size_xend = 5,
dot_guide=TRUE, dot_guide_size=0.5) +
geom_dumbbell(data = df_2019_2020 %>% filter(diff <0),
aes(y=region, x=happiness_2019, xend=happiness_2020),
size=1.5, color="#edae52",
colour_xend = "#edae52", colour_x = "#edae52",
size_x = 2.5, size_xend = 5,
dot_guide=TRUE, dot_guide_size=0.5) +
scale_y_discrete(limits = levels(df_2019_2020$region), expand=c(0.075,1)) +
labs(x='', y=NULL,
title="Happiness in pre to amidst Covid",
subtitle = 'Regions see increases in happiness, despite Covid',
caption= 'Source: World Happiness Report (2021)') +
geom_rect(data=df_2019_2020,
aes(xmin=7.35, xmax=7.65, ymin=-Inf, ymax=Inf),
fill="#e3e2e1") +
geom_text(data=df_2019_2020 %>% filter(region == 'South Asia'),
aes(x=happiness_2020, y=region, label= "2020"),
color="gray15", size=3, vjust=-1.5) +
geom_text(data=df_2019_2020 %>% filter(region == 'South Asia'),
aes(x=happiness_2019, y=region, label= "2019"),
color="gray15", size=3, vjust=-1.5) +
geom_text(data=df_2019_2020 %>% filter(diff>0),
aes(x=happiness_2020 , y=region, label=round(happiness_2020,2)),
size=4, hjust=-0.5) +
geom_text(data=df_2019_2020 %>% filter(diff>0),
aes(x=happiness_2019 , y=region, label=round(happiness_2019,2)),
color="gray15", size=4, hjust=1.3) +
geom_text(data=df_2019_2020 %>% filter(diff<0),
aes(x=happiness_2020 , y=region,
label=round(happiness_2020,2)),size=4, hjust=1.5) +
geom_text(data=df_2019_2020 %>% filter(diff<0),
aes(x=happiness_2019 , y=region,
label=round(happiness_2019,2)),
color="gray15", size=4, hjust=-0.3) +
geom_text(data=df_2019_2020 %>%
filter(region == 'South Asia'),
aes(x=7.5, y=region, label="DIFF"),
size=4.5, vjust=-1.5, fontface="bold") +
geom_text(data=df_2019_2020, aes(label=round(diff,2),
y=region, x=7.5), size=3) +
theme_ipsum(grid="") +
theme(plot.title = element_text(size=20),
plot.subtitle = element_text(size = 15),
plot.caption = element_text(size = 12),
axis.title.x = element_text(size= 12, color = '#3a403a'),
axis.text.y = element_text(size = 15, color = 'black'),
axis.text.x = element_blank(),
legend.position = 'left')