Skip to content

Instantly share code, notes, and snippets.

View mavam's full-sized avatar

Matthias Vallentin mavam

View GitHub Profile
@mavam
mavam / dark_save.R
Last active May 16, 2022 09:24
A ggsave wrapper to store both a light and dark themed version of a plot.
# Wraps ggsave to produce both light and dark themed plot using ggdark.
dark_save <- function(filename, plot, sep = "-", ...) {
require(tools)
require(ggdark)
base <- file_path_sans_ext(filename)
ext <- file_ext(filename)
base_light <- paste(base, "light", sep = "-")
base_dark <- paste(base, "dark", sep = "-")
filename_light <- paste(base_light, ext, sep = ".")
filename_dark <- paste(base_dark, ext, sep = ".")