set.seed(123)p <-ggplot(edu_exp4, aes(x=year, y=fct_reorder(entity,value))) +geom_tile(aes(fill = value),color="black") +geom_vline(aes(xintercept=c(1969.5)),linetype="dashed",size=1,alpha=0.2)+geom_vline(aes(xintercept=c(1979.5)),linetype="dashed",size=1,alpha=0.2)+geom_vline(aes(xintercept=c(1989.5)),linetype="dashed",size=1,alpha=0.2)+geom_vline(aes(xintercept=c(1999.5)),linetype="dashed",size=1,alpha=0.2)+geom_vline(aes(xintercept=c(2009.5)),linetype="dashed",size=1,alpha=0.2)+geom_vline(aes(xintercept=c(2019.5)),linetype="dashed",size=1,alpha=0.2)+scale_fill_gradient(low="white",high="blue",breaks=c(1.5,12),labels=c("Min","Max")) +guides(fill =guide_colourbar(barwidth =9, barheight =2,title.position ="top",label = F,ticks =FALSE))+scale_x_continuous(expand=c(0,0),breaks=seq(1970,2019,10),label=c("1970-1979","1980-1989","1990-1999","2000-2009","2010-2019"))+labs(title ="Government expenditure on education", subtitle="Selected countries with on average total (% of GDP) between 3 and 9%",caption="#30DayChartChallenge 2022 #Day23 -Tiles DataSource: UNESCO Institute for Statistics via OurWorldInData\n DataViz: Federica Gazzelloni",x="",y="",fill="AVG tot GDP %")+theme_ipsum()+theme(text=element_text(size=12,face="bold",family="Roboto Condensed"),axis.text.x =element_text(size=16,vjust=0.5,hjust=-0.5),axis.text.y =element_text(size=15),plot.title =element_text(size=42,family="Roboto Condensed"),plot.subtitle =element_text(family="Roboto Condensed",size=18,face="bold"),plot.caption =element_text(family="Roboto Condensed",size=15,hjust=1,face="bold"),plot.title.position ="panel",plot.background =element_rect(color="grey80",fill="grey80"),panel.background =element_rect(color="grey80",fill="grey80"),legend.title =element_text(size=18,vjust=1,color="grey30"),legend.text =element_text(size=18,color="grey30"),legend.position =c(0,-0.09),legend.direction ="horizontal",plot.margin =margin(10,10,10,1,unit ="pt"))+annotate("text",x=1975,y=-4,label="How to read it:\n- white means 0/empty-value\n- color gradient range on avg between 3 and 9%\n- avg calculated from 1970 to 2019",hjust =0)+coord_cartesian(ylim=c(1,50),clip="off")p#ggplotly(p)ggsave("day23_tiles.png",dpi=320,width =12,height =14)