Set the motif of the chart, defaults to light.

motif(
  g,
  ...,
  brandColor = NULL,
  backgroundColor = "transparent",
  renderer = c("canvas", "svg"),
  padding = "auto",
  visible = TRUE
)

global_motif(
  ...,
  brandColor = NULL,
  backgroundColor = "transparent",
  renderer = c("canvas", "svg"),
  padding = "auto",
  visible = TRUE
)

motif_from_json(g, path)

motif_from_list(g, motif)

motif_as_list(..., brandColor = NULL, backgroundColor = "transparent")

Arguments

g

An object of class g2r or g2Proxy as returned by g2() or g2_proxy().

...

Key value pair defining style, or element().

brandColor

Main default color.

backgroundColor

Plot background color.

renderer

Renderer to use, defaults to canvas.

padding

An integer, or a vector of length 4.

visible

Whether the chart is visible.

path

Path to JSON file.

motif

List defnining the theme, similar to JSON.

Details

The function motif_from_json() can be used to define the theme from a JSON file of theme, to see the default theme file: system.file("theme.json", package = "g2r").

Functions

  • motif: Defines the motif of a visualisation.

  • motif_from_json: Defines the motif from a JSON file of theme, see the theme file. system.file("theme.json", package = "g2r")

  • motif_from_list: Defines the motif from a list, derived from the JSON file.

  • motif_as_list: Returns a motif as a list to use with motif_from_list().

  • global_motif: Define a global motif that will be used by all subsequent charts.

Examples

g2(iris, asp(Sepal.Width, Sepal.Length)) %>%
  fig_point(
    asp(color = Species, shape = "circle")
  ) %>%
  motif(
    brandColor = "orange",
    backgroundColor = "black",
    elementPoint(
      shape = "circle",
      stroke = "white",
      fillOpacity = .7
    )
  )