guide_axis_mark ¶
guide_axis_mark(
*,
spread: Literal["nearest", "even"] | None = None,
link_width: Number | None = None,
padding: Number | None = None,
) -> FeatureSpec
Axis guide that labels the scale's breaks with leader lines (ComplexHeatmap anno_mark).
Pick the breaks to label with the scale's breaks= (for example a few genes
of a heatmap's rows), and its limits= to keep the axis order (without
limits a discrete axis moves its breaks to the front, as in lets-plot). Their
labels are spread along the axis so they never
overlap, and a line links each break's true position to its label: straight
out for a third of the link, slanted over the middle third, straight into the
label. Works on any axis side (position=), under coord_flip(), and on
side panel axes (scale_xsidey_*(), scale_ysidex_*()). Labels take the
axis text theme (axis_text_y=element_text(face="italic")); on top and
bottom axes they read upwards, and the theme's text angle is not applied. The
link takes the axis ticks' line (the label colour when ticks are blank). A
ggrust guide: lets-plot and ggplot2 have no equivalent.
In HTML output with zoom (ggtb()), zoomed labels sit at their breaks
without links; resetting the zoom restores the spread layout.
Parameters:
-
spread((nearest, even), default:"nearest") –"nearest": each label at its break when there is room, pushed apart only as far as needed (anno_mark)."even": equal slots over the whole axis, in break order. -
link_width(float, default:20) –Pixels across the axis the link takes past the ticks (
anno_mark's 5 mm). -
padding(float, default:4) –Pixels kept between neighbouring labels (
anno_mark's 1 mm).
Returns:
-
FeatureSpec–Guide specification for
scale_*(guide=...)orguides(x=...).
Raises:
-
SpecError–If
spreadis unknown. -
UnsupportedValueError–If
spreadis not a string, orlink_widthorpaddingis not a number of 0 or more.
Examples:
>>> from ggrust import *
>>> data = {"fruit": ["apple", "banana", "cherry", "date", "fig", "grape"],
... "month": ["Jan"] * 6, "sales": [3, 5, 2, 8, 6, 4]}
>>> plot = (
... ggplot(data, aes("month", "fruit", fill="sales"))
... + geom_tile()
... + scale_y_discrete(
... breaks=["banana", "cherry", "grape"],
... limits=data["fruit"],
... guide=guide_axis_mark(),
... )
... )