Compose guides using primitives and stacking
mainBeyond complete guides, legendry introduces 'incomplete guides' (primitives) that can be composed into full guides.
One way to compose them is using guide_axis_stack(), which allows you to stack a primitive guide on top of a regular guide (like "axis") to complete it. For example, primitive_bracket() can be used to display a range on an axis when stacked.
When using primitives like primitive_bracket(), you can configure:
key: Determines what is displayed (e.g.,key_range_manual(start, end, name)).bracket: The shape of the bracket (e.g.,"square").theme: Aggplot2theme object to style the legend text or axis text.
# A partial guide to display a bracket
efficient_bracket <- primitive_bracket(
key = key_range_manual(start = 25, end = Inf, name = "Efficient"),
bracket = "square",
theme = theme(
legend.text = element_text(angle = 90, hjust = 0.5),
axis.text.y.left = element_text(angle = 90, hjust = 0.5)
)
)
# Stack the primitive with a regular axis
base + guides(y = guide_axis_stack("axis", efficient_bracket))