guide_axis_stack: Stacked axis guides

View source: R/guide-axis-stack.R

guide_axis_stackR Documentation

Stacked axis guides

Description

This guide can stack other position guides that represent position scales, like those created with scale_(x|y)_continuous() and scale_(x|y)_discrete().

Usage

guide_axis_stack(
  first = "axis",
  ...,
  title = waiver(),
  theme = NULL,
  spacing = NULL,
  order = 0,
  position = waiver()
)

Arguments

first

A position guide given as one of the following:

  • A string, for example "axis".

  • A call to a guide function, for example guide_axis().

...

Additional guides to stack given in the same manner as first.

title

A character string or expression indicating a title of guide. If NULL, the title is not shown. By default (waiver()), the name of the scale object or the name specified in labs() is used for the title.

theme

A theme object to style the guide individually or differently from the plot's theme settings. The theme argument in the guide overrides, and is combined with, the plot's theme.

spacing

A unit() objects that determines how far separate guides are spaced apart.

order

A positive integer of length 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 secret algorithm.

position

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

Details

The first guide will be placed closest to the panel and any subsequent guides provided through ... will follow in the given order.

Examples

#' # A standard plot
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  theme(axis.line = element_line())

# A normal axis first, then a capped axis
p + guides(x = guide_axis_stack("axis", guide_axis(cap = "both")))

ggplot2 documentation built on June 22, 2024, 11:35 a.m.