params <- list(family = "violet", preset = "midnight", base_size = 13L, content_width = 80L, style = "minimal") ## ----setup, include=FALSE----------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.align = "center", fig.retina = 2, out.width = "100%", fig.width = 7, fig.asp = 0.618, message = FALSE, warning = FALSE ) `%||%` <- function(a, b) if (is.null(a)) b else a library(ggplot2) if (requireNamespace("ggplot2", quietly = TRUE) && requireNamespace("albersdown", quietly = TRUE)) { ggplot2::theme_set(albersdown::theme_albers( family = params$family, preset = params$preset, base_size = params$base_size )) } ## ----albers-family, echo=FALSE, results='asis'-------------------------------- cat(sprintf('', params$family)) ## ----albers-preset, echo=FALSE, results='asis'-------------------------------- cat(sprintf('', params$preset)) ## ----albers-style, echo=FALSE, results='asis'--------------------------------- style_class <- switch( tolower(params$style %||% "balanced"), minimal = "style-minimal", assertive = "style-assertive", balanced = "" ) if (nzchar(style_class)) { cat(sprintf('', style_class)) } cat(sprintf('', params$content_width)) ## ----dark-preview------------------------------------------------------------- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point(size = 2.2) + albersdown::scale_color_albers_distinct() + labs( title = "Midnight preset on a vignette page", subtitle = "Dark ground with high-contrast family accents", colour = "cyl" ) ## ----accent-families, fig.height=5.6------------------------------------------ families <- c("red", "lapis", "ochre", "teal", "green", "violet") accent_a700 <- vapply(families, function(f) albersdown::albers_palette(f)[["A700"]], character(1)) plot_df <- do.call(rbind, lapply(seq_along(families), function(i) { d <- mtcars d$family <- families[[i]] d$mpg_offset <- d$mpg + (i - (length(families) + 1) / 2) * 0.25 d })) ggplot(plot_df, aes(wt, mpg_offset, colour = family)) + geom_point(alpha = 0.85, size = 1.7) + facet_wrap(~family, ncol = 3) + scale_color_manual(values = accent_a700) + labs( title = "A700 accents across all families", subtitle = "Same geometry, different accent family", x = "wt", y = "mpg (offset)" ) + theme(legend.position = "none") ## ----recipes-table------------------------------------------------------------ recipes <- data.frame( profile = c("dark-violet-minimal", "dark-lapis-minimal", "dark-teal-assertive"), family = c("violet", "lapis", "teal"), preset = c("midnight", "midnight", "midnight"), style = c("minimal", "minimal", "assertive"), stringsAsFactors = FALSE ) knitr::kable(recipes, format = "html")