# 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)
)
Run the code above in your browser using DataLab