So, I read this post , and I fell in love a little with the calendar heatmap with monthly Tetris-style breaks.
However, the ggplot example ggplot not implement Tetris breaks, which are arguably the best.
So, FTFY, gist here :

The procedure for this:
- create appropriate cracks for your data
left_join your data for Tetris breaks created in (1)- deflate above using
ggplot using custom geom
The methodology for (1) is quite simple, implemented in the calendar_tetris_data(...) function in gist , although it would be nice to make it a little more flexible.
My question is mainly around (3): how do I collect the 7 geom needed to take breaks in one procedure or geom ?
If I do this:
calendar_tetris_geoms <- function() { geom_segment(aes(x=x, xend=x, y=ymin, yend=ymax)) + # (a) geom_segment(aes(x=xmin, xend=xmax, y=y, yend=y)) + # (b) geom_segment(aes(x=dec.x, xend=dec.x, y=dec.ymin, yend=dec.ymax)) + # (c) geom_segment(aes(x=nye.xmin, xend=nye.xmax, y=nye.y, yend=nye.y)) + # (d) geom_segment(x=-0.5, xend=51.5, y=7.5, yend=7.5) + # put a line along the top geom_segment(x=0.5, xend=52.5, y=0.5, yend=0.5) + # put a line along the bottom geom_text(aes(x=month.x, y=month.y, label=month.l), hjust=0.25) # (e) }
And then try adding this to my ggplot , this will not work:
> ggplot(data) + calendar_tetris_geoms() Error in calendar_tetris_geoms() : argument "plot" is missing, with no default
I clearly donโt understand how this works. How it works?