library(tidyverse)
<- tidytuesdayR::tt_load(2021, week = 28)
tuesdata
<- tuesdata$holidays
holidays names(holidays)
library(maps)
library(sf)
::map("world") maps
<- sf::st_as_sf(map("world",plot=FALSE,fill=TRUE))
world <- cbind(world, sf::st_coordinates(sf::st_centroid(world))) world
<- holidays %>%
holidays_map filter(str_detect(name_of_holiday,"(?i)inde"))%>%
left_join(world, by=c("country"="ID")) %>%
select(country,date_parsed,name_of_holiday,independence_from,X,Y)%>%
mutate(country=as.factor(country))
library(showtext)
library(extrafont)
showtext.auto(enable=FALSE)
“#EEE9E9”
<- ggplot2::map_data("world") %>%
mapdata filter(!region==c("Antartica","Greenland","French Southern and Antartic Lands")) %>%
mutate(region=recode(region,
USA="United States",
UK="United Kingdom"))
<- ggplot() +
final_plot geom_map(data=mapdata,map = mapdata,aes(map_id=region),fill= "#F0F8FF",color= "#FAEBD7")+
geom_point(data=world,aes(x=X,y=Y),size=1,color="grey",alpha=0.3)+
geom_point(data=holidays_map,aes(x=X,y=Y),size=0.5,color="black")+
geom_text(data=holidays_map,aes(x=X,y=Y,label=country),family="Andalus",
check_overlap = TRUE,size=1.5,color="#363636",hjust=0,vjust=0)+ #
geom_text(data=holidays_map,aes(x=X,y=Y,label=date_parsed),
family="Andalus", check_overlap = TRUE,size=0.8,
color="#CD1076",vjust=0.8,hjust=-1)+
expand_limits(x=mapdata$long,y=mapdata$lat)+
coord_map(projection = "mercator",xlim=c(-180,180)) +
labs(title="Date parsed: Independent Days celebrating Countries",
caption= "DataViz: @fgazzelloni, DataSource: International Independence Days, Wikipedia,WorldAtlas.com - #TidyTuesday w28")+
guides(fill="none") +
::theme_map()+
ggthemestheme(axis.text = element_blank(),
plot.background = element_rect(fill="#C5E5F0",color="#E0EEEE"),
plot.title = element_text(color="#363636",family="Andalus",size=18,face="bold"),
plot.caption = element_text(size=10))
final_plot
###################### SAVING ############################
::agg_png(here::here("w28","w28_independence_days.png"),
raggres = 320, width = 14, height = 8, units = "in")
final_plot
dev.off()
##################################################