knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", fig.align = "center", out.width = "80%", dev = "ragg_png", dpi = 132 )
This is just a repo where I store my plot defaults for the {ggplot2} package. It is in package format so I wouldn't need to repeat it for every script. The theming and such isn't particularly good, noteworthy or quirky, it is just to easily replace the default gray theme with yet another vanilla theme.
You can install {myplotdefaults} like so:
# install.packages("remotes") remotes::install_github("teunbrand/myplotdefaults")
This is a basic example which shows you how to solve a common problem:
library(myplotdefaults) library(ggplot2) p <- ggplot(mtcars, aes(mpg, disp)) + geom_point() set_defaults() p + ggtitle("The defaults substitutes black for dark grey") set_defaults(ink_colour = "blue") p + ggtitle("Ink colour changes foreground") set_defaults(ink_colour = "white", paper_colour = "black", shadow_colour = "grey10") p + ggtitle("Paper and shadow colour set background and gridline colours")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.