One call in a document's setup chunk: checks the fonts, makes
theme_maison() the default ggplot2 theme and theme_maison_tt() the
default tinytable theme. Every chart and table after it picks up the house
style with no further calls.
Usage
set_maison(
base_family = "Hanken Grotesk",
dark = FALSE,
background = NULL,
fallback = TRUE,
plot_margin = ggplot2::margin(0, 0, 0, 0)
)Arguments
- base_family
The font family for charts. Any installed family works.
- dark
TRUEsets charts and table rules for dark slides.- background, fallback, plot_margin
Passed to
theme_maison(): the chart background (NULL,"transparent"or a color), whether a missingbase_familyfalls back to"sans", and the margin around every chart (none by default).
Value
Invisibly, a list with the previous theme and options, so the
call can be undone with ggplot2::theme_set(old$theme) and
options(old$options).
Details
set_maison() sets exactly two pieces of session state: the default
ggplot2 theme, with ggplot2::theme_set(), and the tinytable_tt_theme
option. It never calls update_geom_defaults() or sets ggplot2.*
options; geom defaults and palettes travel inside the theme.
It warns when the session already has ggplot2.discrete.* or
ggplot2.continuous.* options set, because ggplot2 lets those override a
theme's palettes. When base_family is not available it warns once per session
and, unless fallback = FALSE, draws charts in "sans"; see
theme_maison().
Examples
old <- set_maison(base_family = "sans")
library(ggplot2)
ggplot(mpg, aes(class, fill = drv)) + geom_bar()
tinytable::tt(head(mtcars[1:4]))
#>
#> +---------+---------+----------+--------+
#> | **mpg** | **cyl** | **disp** | **hp** |
#> +=========+=========+==========+========+
#> | 21.0 | 6 | 160 | 110 |
#> +---------+---------+----------+--------+
#> | 21.0 | 6 | 160 | 110 |
#> +---------+---------+----------+--------+
#> | 22.8 | 4 | 108 | 93 |
#> +---------+---------+----------+--------+
#> | 21.4 | 6 | 258 | 110 |
#> +---------+---------+----------+--------+
#> | 18.7 | 8 | 360 | 175 |
#> +---------+---------+----------+--------+
#> | 18.1 | 6 | 225 | 105 |
#> +---------+---------+----------+--------+
# put things back
theme_set(old$theme)
options(old$options)