theme_ext: Modify the text, margins, or legend for a ggplot theme

theme_extR Documentation

Modify the text, margins, or legend for a ggplot theme

Description

Helper functions for modifying a ggplot theme. The "replace" and "update" options for the method parameter are not currently working; keeping method = NULL or method = "set" is recommended.

Usage

theme_text(
  font_family = NULL,
  color = "black",
  geom_text = TRUE,
  hjust = NULL,
  vjust = NULL,
  method = NULL
)

theme_margin(
  margin = "standard",
  paper = NULL,
  orientation = NULL,
  dist = NULL,
  unit = "in",
  plot_width = NULL,
  header = 0,
  footer = 0,
  fill = NA,
  color = NA,
  size = 0,
  method = NULL
)

theme_legend(
  position = NULL,
  justification = NULL,
  margin = 8,
  unit = "pt",
  inset = TRUE,
  bgcolor = "white",
  title = list(face = "bold", align = 0),
  method = NULL
)

Arguments

font_family

Font family, Default: 'Helvetica' If NULL, font_family is pulled from current set theme which is helpful for resetting all text families to the theme.

color

Color for text elements (passed to ggplot2::element_text() by theme_text), plot.background (passed to ggplot2::element_rect() by theme_margin). Default: NA.

geom_text

If TRUE, update text family for ggplot2::geom_text(), ggplot2::geom_sf_text(), ggplot2::geom_label(), and ggplot2::geom_sf_label() to match font_family and color. If FALSE, make no changes to the theme. Default: TRUE.

hjust, vjust

Horizontal and vertical justification.

method

Method with name of the ggplot2 geom function to use for modifying theme ("set", "update", or "replace"); defaults to NULL.

margin

Margin distance, a margin style supported by get_margin() or a margin object; defaults to 10.

paper

Paper, Default: 'letter'.

orientation

Orientation "portrait", "landscape", or "square", Default: 'portrait'.

dist

Margin distance (single value used to all sides), Default: NULL

unit

Legend margin units; defaults to 'pt'.

plot_width

Plot or map width in units. If paper and plot_width are provided, margins are half the distance between the two evenly distributed. This sets the margin distance for height as well as width so does not work well with header and footers and should be improved in the future.

header, footer

Header and footer height in units; defaults to 0. Please note: headers and footers are not currently supported for "px" units.

fill

Fill for plot.background theme element passed to ggplot2::element_rect() Default: NA.

size

Size number (only used for "ISO" and "JIS" series). Standard, series, and size may all be required to return a single paper when using these parameters.

position

Legend position (“left”,“top”, “right”, “bottom”) or a two-element numeric vector to set position using Normalized Parent Coordinates ("npc"); defaults NULL

justification

If NULL, justification is set to "center"; defaults to NULL. Use justification to set legend position if inset = FALSE. Supports "topleft", "bottomleft", "topright", or "bottomright" values.

inset

If TRUE and position is "topleft", "bottomleft", "topright", or "bottomright", place the legend in an inset position; defaults to TRUE.

bgcolor

Fill color for legend background; defaults to 'white'.

title

Attributes to use for legend.title text (e.g. face and align).

See Also

  • ggplot2::theme()

  • ggplot2::margin()

  • ggplot2::theme_get()

  • ggplot2::update_geom_defaults()


elipousson/overedge documentation built on Aug. 13, 2022, 7:41 p.m.