Figure 1: Plot showing the average maximum annual rainfall and temperatures across major Australian cities from 1900-2019. Australia was experiencing a 60-year drought, and at that point in 2019, the hottest temperatures on record. Source: Australian Bureau of Meteorology. Inspiration: Tidy Tuesday work from jkaupp.
plot_rainfall<-annual_rainfall%>%filter(year>=1900&year<2020)%>%mutate(ma10 =zoo::rollapply(annual_rainfall, width=10, FUN=mean, align='right', partial =TRUE))%>%ggplot(.,aes(x=year, y=annual_rainfall))+geom_line(color ='cornflowerblue')+geom_point(color ='cornflowerblue')+geom_line(aes(y=ma10), linetype='longdash', color='gray30')+geom_mark_circle(aes(filter =year==2019, label =glue("Total Rainfall: {round(annual_rainfall,1)} mm"), description ="Annual rainfall at a 60 year low"), label.family =c("Roboto", "Roboto Condensed"), label.buffer =unit(6, "cm"), label.fontsize =18)+scale_x_continuous(limits =c(1900, 2020), breaks =seq(1900, 2020, 20))+labs(x='', y='')+scale_y_continuous(limits =c(10, 50), breaks =seq(10, 50, 10), labels =scales::label_number(suffix =" mm"))+my_themeplot_temperature<-annual_temperature%>%mutate(ma10 =zoo::rollapply(avg_temperature, width=10, FUN=mean, align='right', partial =TRUE))%>%ggplot(.,aes(x=year, y=avg_temperature))+geom_line(color ='firebrick3')+geom_point(color ='firebrick3')+geom_line(aes(y=ma10), linetype='longdash', color='gray30')+geom_mark_circle(aes(filter =year==2019, label =glue("Avg Max Temp: {round(avg_temperature, 1)}°C"), description ="Data through May 2019"), label.family =c("Roboto", "Roboto Condensed"), label.buffer =unit(6, "cm"), label.fontsize =18)+labs(x='', y='')+scale_x_continuous(limits =c(1900, 2020), breaks =seq(1900, 2020, 20))+# scale_y_continuous(limits = c(10, 30), breaks = seq(10, 30, 10), label = label_number(unit = "° C", sep = ""), position = "right") +scale_y_continuous(limits =c(10, 30), breaks =seq(10, 30, 10), labels =scales::label_number(suffix ="°C"), position ="right")+my_themeplot_rain_temp<-plot_rainfall+plot_temperature+theme(plot.margin =margin(r =30, l =30))+plot_annotation( title ="Historic Lows in Rainfall and Records High Temperatures a Factor in Australia's Devastating Wildfires", subtitle =glue("<span style='color:cornflowerblue'>**Total rainfall**</span> and <span style='color:firebrick3'>**average maximum temperature**</span> across Australian cities from 1900 to 2019"), caption ="Tidy Tuesday Week 2 (2020). **Source**: Australian Bureau of Meterology", theme =theme( plot.title =element_textbox_simple(family='Roboto', size=48, face='bold'), plot.subtitle =element_textbox_simple(family='Roboto', size=34), plot.caption =element_textbox_simple(family ='Roboto', size=18)))
7. Save
Show code
# Save the plot as PNGggsave( filename =glue("tt_{tt_year}_{tt_week}.png"), plot =plot_rain_temp, width =10, height =6, units ="in", dpi =320)# make thumbnail for pagemagick::image_read(glue("tt_{tt_year}_{tt_week}.png"))%>%magick::image_resize(geometry ="400")%>%magick::image_write(glue("tt_{tt_year}_{tt_week}_thumbnail.png"))