primitive_segments {legendry} | R Documentation |
Guide primitives: segments
Description
This function constructs a guide primitive.
Usage
primitive_segments(
key = NULL,
space = rel(10),
vanish = FALSE,
theme = NULL,
position = waiver()
)
Arguments
key |
A segment key specification. See more information
in the linked topic. Alternatively, an object of class
|
space |
Either a |
vanish |
Only relevant when the guide is used in the secondary theta
position: a |
theme |
A |
position |
A |
Value
A <PrimitiveSegments>
primitive guide that can be used inside other
guides.
Styling options
Below are the theme options that determine the style of this guide, which may differ depending on whether the guide is used in an axis or in a legend context.
As an axis guide
-
axis.ticks.{x/y}.{position}
an<element_line>
for display of the segments. -
axis.ticks.length.{x/y}.{position}
a<unit>
for the base size of the segments in the orthogonal direction.
As a legend guide
-
legend.ticks
an<element_line>
for display of the segments. -
legend.ticks.length
a<unit>
for the base size of the segments in the orthogonal direction.
See Also
Other primitives:
primitive_box()
,
primitive_bracket()
,
primitive_fence()
,
primitive_labels()
,
primitive_line()
,
primitive_spacer()
,
primitive_ticks()
,
primitive_title()
Examples
# Building a key
key <- key_segment_manual(
value = c(1.6, 1.6, 3.4, 5.2),
value_end = c(7.0, 7.0, 3.4, 5.2),
oppo = c(1.0, 2.0, 0.0, 0.0),
oppo_end = c(1.0, 2.0, 3.0, 3.0)
)
# Using the primitive in a plot
ggplot(mpg, aes(displ, hwy)) +
geom_point() +
scale_x_continuous(
guide = primitive_segments(key = key)
)