I am making a calendar using ggplot2. I'd like the calendar to look like this:
library(tidyverse)
library(lubridate)
library(ggforce)
datedb <- tibble(date = seq(as.Date("2021-09-01"),
as.Date("2021-12-31"), by = 1),
day = day(date),
week_no = epiweek(date),
Month = month(date, label = TRUE, abbr = FALSE),
Wday = wday(date, label = TRUE, abbr = TRUE))
ggplot(datedb, aes(Wday, week_no)) +
geom_tile(color = "black", fill = NA) +
geom_text(aes(label = day), size = 3) +
scale_y_reverse() +
scale_x_discrete(position = "top") +
facet_wrap(~ Month, ncol = 1, scales = "free",
strip.position = "top") +
theme_void() +
theme(axis.text.x = element_text(size = 9),
strip.placement = "outside",
strip.text = element_text(size = 13))
However, I noticed that the tiles in the month of October are smaller than the other months - October has one more row of days than the other months. I'd like to make all the cells the same size. I can use the facet_col argument in ggforce instead of facet_wrap to do this: ggforce::facet_col(vars(Month), scales = "free_y", space = "free") +
... but then I loose my x-axis labels (see image below), which are important - I'd like each month to show days of the week.
Is there any "easy" solution to keep my grid cells the same size and my x-axis labels?


