Last active
May 16, 2022 09:24
-
-
Save mavam/4dc61297f478744fc3231bd5949f85f8 to your computer and use it in GitHub Desktop.
A ggsave wrapper to store both a light and dark themed version of a plot.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = ".") | |
ggsave(filename = filename_light, plot, ...) | |
ggsave(filename = filename_dark, plot + dark_mode(plot$theme), ...) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment