Skip to contents

[Experimental]

This guide composition has a middle guide flanked by two parallel guides.

Usage

compose_sandwich(
  key = key_auto(),
  middle = gizmo_barcap(),
  text = "none",
  opposite = "none",
  args = list(),
  complete = TRUE,
  theme = NULL,
  theme_defaults = list(),
  reverse = FALSE,
  order = 0,
  title = waiver(),
  position = waiver(),
  available_aes = NULL
)

Arguments

key

A standard key specification. The key is shared among all guides that have NULL keys themselves. See more information in the linked topic.

middle

Guide to use as the middle guide. Each guide can be specified as one of the following:

  • A <Guide> class object.

  • A <function> that returns a <Guide> class object.

  • A <character> naming such a function, without the guide_ or primitive_ prefix.

text, opposite

Guides to use at the legend.text.position location and on the opposite side of the middle guide respectively. Guide specification is the same as in the middle argument.

args

A <list> of arguments to pass to guides that are given either as a function or as a string.

complete

A <logical[1]> whether to treat the composition as a complete guide. If TRUE, a title and margin are added to the result. If FALSE (default), no titles and margins are added.

theme

A <theme> object to style the guide individually of differently from the plot's theme settings. The theme arguments in the guide overrides, and is combined with, the plot's theme.

theme_defaults

A <list> of theme elements to override undeclared theme arguments.

reverse

A <logical[1]> whether to reverse continuous guides. If TRUE, guides like colour bars are flipped. If FALSE (default), the original order is maintained.

order

A positive <integer[1]> that specifies the order of this guide among multiple guides. This controls in which order guides are merged if there are multiple guides for the same position. If 0 (default), the order is determined by a hashing indicative settings of a guide.

title

A <character[1]> or <expression[1]> indicating the title of the guide. If NULL, the title is not shown. The default, waiver(), takes the name of the scale object or the name specified in labs() as the title.

position

Where this guide should be drawn: one of "top", "bottom", "left", or "right".

available_aes

A <character> vector listing the aesthetics for which this guide can be build.

Value

A <ComposeSandwich> guide object.

Details

The sandwich composition is effectively the same as a crux composition lacking two opposing arms.

See also

Examples

# A standard plot with a sandwich guide
ggplot(mpg, aes(displ, hwy)) +
  geom_point(aes(colour = cty)) +
  guides(colour = compose_sandwich(
    middle = "colourbar",
    text = "axis_base",
    opposite = primitive_bracket(key = key_range_manual(
      start = c(10, 20), end = c(25, 30), name = c("A", "B")
    ))
  ))