text2map.theme::set_theme provides a clean [ggplot2] theme based the Urban Institute style guide, with [viridis] color scheme.

Replace [ggplot2] scale_colour_discrete with scale_colour_viridis_d

set_theme(
  base_size = 8.5,
  base_line_size = 0.5,
  base_rect_size = 0.5,
  base_family = "Open Sans",
  font_method = "extrafont",
  set_font = FALSE
)

scale_colour_discrete(
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  option = "D",
  aesthetics = "color"
)

scale_fill_discrete(
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  option = "D",
  aesthetics = "fill"
)

scale_colour_continuous(
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  option = "D",
  values = NULL,
  space = "Lab",
  na.value = "grey50",
  guide = "colourbar",
  aesthetics = "colour"
)

scale_fill_continuous(
  ...,
  alpha = 1,
  begin = 0,
  end = 1,
  direction = 1,
  option = "D",
  values = NULL,
  space = "Lab",
  na.value = "grey50",
  guide = "colourbar",
  aesthetics = "fill"
)

Arguments

base_size

base font size

base_line_size

base line sizes

base_rect_size

base rectangle sizes

base_family

base font family: 'Open Sans' (default) or 'Lato'

font_method

"extrafont" or "showtext"

set_font

default is FALSE

...

Other arguments passed on to [discrete_scale()], [continuous_scale()], or [binned_scale] to control name, limits, breaks, labels and so forth.

alpha

The alpha transparency, a number in [0,1], see argument alpha in hsv.

begin, end

The (corrected) hue in [0,1] at which the color map begins and ends.

direction

Sets the order of colors in the scale. If 1, the default, colors are ordered from darkest to lightest. If -1, the order of colors is reversed.

option

A character string indicating the color map option to use. Eight options are available:

  • "magma" (or "A")

  • "inferno" (or "B")

  • "plasma" (or "C")

  • "viridis" (or "D")

  • "cividis" (or "E")

  • "rocket" (or "F")

  • "mako" (or "G")

  • "turbo" (or "H")

aesthetics

Character string or vector of character strings listing the name(s) of the aesthetic(s) that this scale works with. This can be useful to apply color settings to the `colour` and `fill` aesthetics at the same time, via `aesthetics = c("colour", "fill")`.

values

if colours should not be evenly positioned along the gradient this vector gives the position (between 0 and 1) for each colour in the colours vector. See rescale() for a convenience function to map an arbitrary range to between 0 and 1.

space

colour space in which to calculate gradient. Must be "Lab" - other values are deprecated.

na.value

Missing values will be replaced with this value.

guide

A function used to create a guide or its name. See guides() for more information.

Details

The function can also set the font as either "Open Sans" or "Lato." Setting fonts is tricky because it depends on your system and the fonts installed and should be considered experimental.

Author

Dustin Stoltz