The white space here is annoying, and it ruins the whole aesthetic of the plot. The source of the issue is not ggplot, however, it occurs because the png file generated by R markdown has a different aspect ratio than the one that ggplot specifies The result is that the graphics device (png() in this case) supplies its own background colour, which defaults to white. Happily, knitr allow us to pass custom arguments to the graphics device, and slumdown provides a convenience function that does this:

slum_plot_background("kunoichi")

So now when we create the figure, the background is seamless because ggplot, the graphics device and the HTML page all rely on the “pagecolour” value specified in the kunoichi palette:

b + facet_wrap(vars(Time), nrow=5)

Alternatively, using theme_void() will remove all ggplot2 theme information, so now the background colour is supplied by the graphics device, and we can obtain animations like this