Skip to contents

Weave the style by setting:

  1. the mode to be added with gg_*() side-effects

  2. the colour/fill geom default, and other defaults for text, reference line and curve geoms

  3. the col_palettes for discrete, continuous and ordinal colour/fill scales

  4. a theme to be added without gg_*() side-effects.

Alternatively, use the weave_* functions to only apply a subset of these. ggplot2::update_geom_defaults() can be used to further fine-tune geom defaults.

Usage

set_blanket(
  ...,
  mode = light_mode_r(),
  colour = "#357BA2FF",
  fill = colour,
  text_colour = "#121B24FF",
  text_size = 11/2.835052,
  text_family = "",
  reference_line_colour = "#121B24FF",
  reference_line_linewidth = 0.33,
  col_palette_d = jumble,
  col_palette_na_d = "#CDC5BFFF",
  col_palette_c = viridisLite::mako(n = 9, direction = -1),
  col_palette_na_c = "#988F88FF",
  col_palette_o = scales::pal_viridis(option = "G", direction = -1),
  col_palette_na_o = "#988F88FF",
  theme = light_mode_r() + mode_orientation_to_x()
)

Arguments

...

Provided to force user argument naming etc.

mode

A ggplot2 theme (e.g. light_mode_t() or dark_mode_r()) that anticipates gg_* side-effects of removing relevant axis line/ticks and gridlines per the mode_orientation.

colour

A default hex colour for the colour of geoms (other than text or reference line geoms).

fill

A default hex colour for the fill of geoms (other than text or reference line geoms).

text_colour

A default hex colour for the colour (and fill) of the "text" and "label" geoms.

text_size

A default size for the "text" and "label" geoms.

text_family

A default family for the "text" and "label" geoms.

reference_line_colour

A default hex colour for the colour of the "hline", "vline", "abline" and "curve" geoms.

reference_line_linewidth

A default linewidth for the the "hline", "vline", "abline" and "curve" geoms.

col_palette_d

For a discrete scale, a character vector of hex codes.

col_palette_na_d

For a discrete scale, a hex code.

col_palette_c

For a continuous scale, a character vector of hex codes.

col_palette_na_c

For a continuous scale, a hex code.

col_palette_o

For an ordinal scale, a scales::pal_*() function.

col_palette_na_o

For an ordinal scale, a hex code.

theme

A ggplot2 theme that the gg_* function will add without side-effects if the mode is set/weaved to NULL (and also is applied to ggplot code outside of ggblanket).

Value

A globally set style.

Examples

library(ggplot2)
library(ggblanket)
library(palmerpenguins)

set_blanket(
  mode = dark_mode_r(),
  colour = "#E7298AFF",
  text_colour = darkness[1],
  reference_line_colour = darkness[1],
  col_palette_d = c("#1B9E77FF", "#D95F02FF", "#7570b3FF", "#E7298AFF",
                    "#66A61EFF", "#E6AB02FF", "#A6761DFF", "#666666FF"),
)

penguins |>
  gg_point(
    x = flipper_length_mm,
    y = body_mass_g,
  ) +
  geom_vline(xintercept = 200) +
  annotate("text", x = I(0.25), y = I(0.75), label = "Here")
#> Warning: Ignoring unknown parameters: `outlier.alpha`
#> Warning: Ignoring unknown parameters: `outlier.alpha`
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).


penguins |>
  gg_histogram(
    x = flipper_length_mm,
    col = species,
  ) +
  geom_vline(xintercept = 200) +
  annotate("text", x = I(0.75), y = I(0.75), label = "Here")
#> Warning: Ignoring unknown parameters: `outlier.alpha`
#> Warning: Ignoring unknown parameters: `outlier.alpha`
#> Scale for colour is already present.
#> Adding another scale for colour, which will replace the existing scale.
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#> Warning: Removed 2 rows containing non-finite outside the scale range (`stat_bin()`).