I’ve put my calendar plot paper on arXiv, which was picked as the top 1 paper in Application on the day. This paper introduced a new calendar-based graphics for visualising people’s daily activities using a data re-structuring approach, implemented in
sugrrants::frame_calendar(). The calendar layout is a clear analogue to facetting, but I didn’t have much success in developing a facetting method for it almost two years ago. I realised why not ask Thomas about the possibilities of
facet_calendar() when he congratulated on Twitter. He pointed out subclassing of
ggroto_parent() to modify the components as desired. It took me one day to get
facet_calendar() done and most time spent figuring out the gtable. The code ended up simple. Now a fully-fledged facetting calendar with formal labels and axes is available in the sugrrants package.
Calendar-based visualisations go beyond calendar heatmap and can unfold many interesting scenes. Some awesome applications can be found here, here, and here. All data is about the past, but we shall be able to create a 2019 🎃-themed calendar with ggplot2.
library(tidyverse) library(lubridate) library(sugrrants) cal19 <- tibble( date = seq(as.Date("2019-01-01"), as.Date("2019-12-31"), by = 1), x = 0L, y = 0L, dom = mday(date), weekend = as.factor(if_else(wday(date, week_start = 1) %in% c(6, 7), 1, 0)) )
cal19 %>% ggplot(aes(x, y)) + geom_text(aes(label = dom, colour = weekend), size = 3) + facet_calendar(date = date, format = "%b", week_start = 7, ncol = 3) + labs( x = "", y = "", title = "2019 Grammar of Calendar-based Graphics ;)", caption = "made with R & <3" ) + theme( strip.background = element_rect(fill = "#881EE4"), panel.background = element_rect(fill = "#000000"), strip.text = element_text(colour = "#FFFFFF"), axis.ticks = element_blank(), axis.text = element_blank(), panel.grid = element_blank() ) + scale_colour_manual(values = c(`1` = "#FF9A00", `0` = "#85E21F")) + guides(colour = "none")