| Title: | Publication-Quality 'ggplot2' Annotation |
|---|---|
| Description: | Annotation helper functions for publication-quality 'ggplot2' visualisation. These functions make it easier to annotate plots in a way that stays consistent with the set theme. |
| Authors: | David Hodge [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-3868-7501>) |
| Maintainer: | David Hodge <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-07-07 04:49:46 UTC |
| Source: | https://github.com/davidhodge931/ggscribe |
Modifies a mapped colour (or fill) aesthetic for contrast against the fill (or colour) aesthetic.
Function can be spliced into ggplot2::aes with rlang::!!!.
aes_contrast(..., dark = NULL, light = NULL, aesthetic = "colour")aes_contrast(..., dark = NULL, light = NULL, aesthetic = "colour")
... |
Unused. Included to support a trailing comma. |
dark |
A dark colour. If NULL, derived from theme text or panel background. |
light |
A light colour. If NULL, derived from theme text or panel background. |
aesthetic |
The aesthetic to be modified for contrast. Either |
A ggplot2 mapping object suitable for use in ggplot2::aes() or as a
mapping = argument in a layer.
Draws one or more brackets along a floating axis line. Each bracket spans
min(breaks) to max(breaks) with caps at every break value.
Requires coord_cartesian(clip = "off").
axis_bracket( xintercept = NULL, yintercept = NULL, breaks, length = ggplot2::rel(1), colour = NULL, linewidth = NULL, linetype = NULL, layout = NULL )axis_bracket( xintercept = NULL, yintercept = NULL, breaks, length = ggplot2::rel(1), colour = NULL, linewidth = NULL, linetype = NULL, layout = NULL )
xintercept |
One or more x positions for vertical axis lines, in data
coordinates or wrapped in |
yintercept |
One or more y positions for horizontal axis lines, in data
coordinates or wrapped in |
breaks |
A numeric vector of length >= 2 in data coordinates, or
wrapped in |
length |
Length of the bracket caps. Supports |
colour |
Inherits from |
linewidth |
Inherits from |
linetype |
Inherits from |
layout |
Controls which panels the annotation appears in. |
Caps always point in the positive direction by default (right for
xintercept, up for yintercept). Use a negative length to flip them
(e.g. length = -rel(1)).
A list of ggplot2 annotation layers.
Draws a full line at one or more floating positions, with style defaults
taken from the axis.line element of the set theme. Requires
coord_cartesian(clip = "off").
axis_line( xintercept = NULL, yintercept = NULL, colour = NULL, linewidth = NULL, linetype = NULL, arrow = NULL, layout = NULL )axis_line( xintercept = NULL, yintercept = NULL, colour = NULL, linewidth = NULL, linetype = NULL, arrow = NULL, layout = NULL )
xintercept |
One or more x positions for vertical axis lines, in data
coordinates or wrapped in |
yintercept |
One or more y positions for horizontal axis lines, in data
coordinates or wrapped in |
colour |
Inherits from |
linewidth |
Inherits from |
linetype |
Inherits from |
arrow |
A |
layout |
Controls which panels the annotation appears in. |
The arrow (if any) points in the positive direction by default — rightward
for xintercept lines, upward for yintercept lines.
A list of ggplot2 annotation layers.
Draws text labels at specified break positions along a floating axis line,
with style defaults taken from the axis.text element of the set theme.
Requires coord_cartesian(clip = "off").
axis_text( xintercept = NULL, yintercept = NULL, breaks, labels = NULL, length = ggplot2::rel(1), angle = 0, hjust = NULL, vjust = NULL, colour = NULL, size = NULL, family = NULL, layout = NULL )axis_text( xintercept = NULL, yintercept = NULL, breaks, labels = NULL, length = ggplot2::rel(1), angle = 0, hjust = NULL, vjust = NULL, colour = NULL, size = NULL, family = NULL, layout = NULL )
xintercept |
One or more x positions for vertical axis lines, in data
coordinates or wrapped in |
yintercept |
One or more y positions for horizontal axis lines, in data
coordinates or wrapped in |
breaks |
A numeric vector of break positions in data coordinates, or
wrapped in |
labels |
One of:
|
length |
Offset from the axis line including tick length and margin.
Supports |
angle |
Text rotation angle. Defaults to |
hjust, vjust
|
Justification. Auto-calculated from axis direction and
|
colour |
Inherits from |
size |
Inherits from |
family |
Inherits from |
layout |
Controls which panels the annotation appears in. |
Text always sits on the positive side of the axis by default (right of
xintercept lines, above yintercept lines). Use a negative length
to place text on the opposite side (e.g. length = -rel(1)).
A list of ggplot2 annotation layers.
Draws axis ticks at specified break positions along a floating axis line.
Requires coord_cartesian(clip = "off").
axis_ticks( xintercept = NULL, yintercept = NULL, breaks, length = ggplot2::rel(1), colour = NULL, linewidth = NULL, linetype = NULL, arrow = NULL, layout = NULL )axis_ticks( xintercept = NULL, yintercept = NULL, breaks, length = ggplot2::rel(1), colour = NULL, linewidth = NULL, linetype = NULL, arrow = NULL, layout = NULL )
xintercept |
One or more x positions for vertical axis lines, in data
coordinates or wrapped in |
yintercept |
One or more y positions for horizontal axis lines, in data
coordinates or wrapped in |
breaks |
A numeric vector of break positions in data coordinates, or
wrapped in |
length |
Total tick length. Supports |
colour |
Inherits from |
linewidth |
Inherits from |
linetype |
Inherits from |
arrow |
A |
layout |
Controls which panels the annotation appears in. |
Ticks always point in the positive direction by default (right for
xintercept, up for yintercept). Use a negative length to flip them
(e.g. length = -rel(1)).
A list of ggplot2 annotation layers.
A wrapper around ggplot2::guide_axis() that defaults to making transparent
ticks and lines while preserving text, making it ideal for annotation labels.
guide_sec_axis_text(..., theme = NULL)guide_sec_axis_text(..., theme = NULL)
... |
Additional arguments passed to |
theme |
A theme object to style the secondary axis. |
A guide object to be used in a scale's guide argument or within
sec_axis_text().
Draws filled rectangles over the panel. Defaults to the panel.background
fill from the set theme at full opacity, making it useful for layering a
solid background over existing content. Should be placed before geom layers.
panel_background( xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, fill = NULL, alpha = 1, colour = NULL, linewidth = NULL, linetype = 0, layout = NULL )panel_background( xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, fill = NULL, alpha = 1, colour = NULL, linewidth = NULL, linetype = 0, layout = NULL )
xmin, xmax
|
Left and right edges of the rectangle in data coordinates.
Defaults to |
ymin, ymax
|
Bottom and top edges of the rectangle in data coordinates.
Defaults to |
fill |
Fill colour. Defaults to the |
alpha |
Opacity. Defaults to |
colour |
Border colour. Defaults to the resolved |
linewidth |
Inherits from |
linetype |
Border linetype. Defaults to |
layout |
Controls which panels the annotation appears in. |
A list containing annotation layers.
Draws gridlines at specified positions, with style defaults taken from the
panel.grid.major element of the set theme. Crop bounds (xmin, xmax,
ymin, ymax) both filter which lines are drawn and control how far they
run across the panel.
panel_grid( xintercept = NULL, yintercept = NULL, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, colour = NULL, linewidth = NULL, linetype = NULL, layout = NULL )panel_grid( xintercept = NULL, yintercept = NULL, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, colour = NULL, linewidth = NULL, linetype = NULL, layout = NULL )
xintercept |
One or more x positions for vertical gridlines, in data
coordinates or wrapped in |
yintercept |
One or more y positions for horizontal gridlines, in data
coordinates or wrapped in |
xmin, xmax
|
Left and right crop bounds. Vertical gridlines outside
|
ymin, ymax
|
Bottom and top crop bounds. Horizontal gridlines outside
|
colour |
Inherits from |
linewidth |
Inherits from |
linetype |
Inherits from |
layout |
Controls which panels the annotation appears in. |
A list of ggplot2 annotation layers.
A convenience wrapper around panel_background() with a smart shade default
which blends the panel background fill with jumble::slate at 25% opacity
with no border. Should be placed before geom layers.
panel_shade( xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, fill = NULL, alpha = 0.2, colour = "transparent", linewidth = NULL, linetype = 1, layout = NULL )panel_shade( xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf, fill = NULL, alpha = 0.2, colour = "transparent", linewidth = NULL, linetype = 1, layout = NULL )
xmin, xmax
|
Left and right edges of the rectangle in data coordinates.
Defaults to |
ymin, ymax
|
Bottom and top edges of the rectangle in data coordinates.
Defaults to |
fill |
Fill colour. |
alpha |
Opacity. Defaults to |
colour |
Border colour. Defaults to |
linewidth |
Inherits from |
linetype |
Border linetype. Defaults to |
layout |
Controls which panels the annotation appears in. |
A list containing annotation layers.
Draws one or more reference lines within the panel, with style defaults
taken from the axis.line element of the set theme.
reference_line( xintercept = NULL, yintercept = NULL, colour = NULL, linewidth = NULL, linetype = "dashed", arrow = NULL, layout = NULL )reference_line( xintercept = NULL, yintercept = NULL, colour = NULL, linewidth = NULL, linetype = "dashed", arrow = NULL, layout = NULL )
xintercept |
One or more x positions for vertical reference lines, in
data coordinates or wrapped in |
yintercept |
One or more y positions for horizontal reference lines, in
data coordinates or wrapped in |
colour |
Inherits from |
linewidth |
Inherits from |
linetype |
Defaults to |
arrow |
A |
layout |
Controls which panels the annotation appears in. |
The arrow (if any) points in the positive direction by default — rightward
for xintercept lines, upward for yintercept lines.
A list of ggplot2 annotation layers.
Secondary axis for text annotations
sec_axis_text( breaks = function(x) mean(x), labels = ggplot2::waiver(), name = NULL, guide = guide_sec_axis_text(), ... )sec_axis_text( breaks = function(x) mean(x), labels = ggplot2::waiver(), name = NULL, guide = guide_sec_axis_text(), ... )
breaks |
A function or numeric vector giving the break position(s) used
to anchor the text. Defaults to |
labels |
One of:
|
name |
The name of the secondary axis. Use |
guide |
A guide object used to render the axis. Defaults to
|
... |
Additional arguments passed to |
A AxisSecondary object for use in the sec.axis argument of
scale_x_continuous() or scale_y_continuous().