This function constructs a ticks guide primitive.
Usage
primitive_ticks(key = NULL, bidi = FALSE, theme = NULL, position = waiver())Arguments
- key
A standard key specification. See more information in the linked topic.
- bidi
A
<logical[1]>: whether ticks should be drawn bidirectionally (TRUE) or in a single direction (FALSE, default).- theme
A
<theme>object to style the guide individually or differently from the plot's theme settings. Thethemeargument in the guide overrides and is combined with the plot's theme.- position
A
<character[1]>giving the location of the guide. Can be one of"top","bottom","left"or"right".
Details
Styling options
Below are the theme options that determine the styling of this guide, which may differ depending on whether the guide is used in an axis or in a legend context.
The ticks can come in three variants: major, minor and minimal.
Which variants are drawn depends on the keys: key_minor() draws major
and minor ticks, whereas key_log() also has minimal ticks.
Each variant has a corresponding length setting.
The possible {position} suffixes mentioned below are x, x.top,
x.bottom, y, y.left, y.right. The theta and r position suffixes
in ggplot2 are not obeyed in legendry.
| Theme setting | Context | Type | Description |
axis.ticks.{position} | Axis | element_line() | Major tick lines |
axis.ticks.length.{position} | Axis | unit() | Major tick length |
axis.minor.ticks.{position} | Axis | element_line() | Minor tick lines |
axis.minor.ticks.length.{position} | Axis | unit() | Minor tick length |
legendry.axis.mini.ticks | Axis | element_line() | Minimal tick lines |
legendry.axis.mini.ticks.length | Axis | unit() | Minimal tick length |
legend.ticks | Legend | element_line() | Major tick lines |
legend.ticks.length | Legend | unit() | Major ticks length |
legendry.legend.minor.ticks | Legend | element_line() | Minor tick lines |
legendry.legend.minor.ticks.length | Legend | unit() | Minor ticks length |
legendry.legend.mini.ticks | Legend | element_line() | Minimal tick lines |
legendry.legend.mini.ticks.length | Legend | unit() | Minimal tick length |
Styling options per break can be set in the key.
The line and prefixed properties are prioritised for the tick lines.
These override theme settings.
The context-agnostic alternative to using theme() is to use
theme_guide():
primitive_ticks(theme = theme_guide(
ticks = element_line(),
ticks.length = unit(5, "mm"),
minor.ticks = element_line(),
minor.ticks.length = unit(4, "mm"),
mini.ticks = element_line(),
mini.ticks.length = unit(3, "mm")
))Examples
# A standard plot
p <- ggplot(mpg, aes(displ, hwy)) +
geom_point()
# Adding as secondary guides
p + guides(x.sec = primitive_ticks(), y.sec = primitive_ticks())
