Skip to contents

Adds one or more reference lines or segments to a plot. Dispatches to the appropriate ggplot2 geom based on the parameters supplied:

Usage

mark_rule(
  plot,
  xintercept = NULL,
  yintercept = NULL,
  slope = NULL,
  intercept = NULL,
  x = NULL,
  xend = NULL,
  y = NULL,
  yend = NULL,
  colour = NULL,
  linetype = NULL,
  linewidth = NULL,
  ...,
  rasterize = FALSE,
  rasterize_dpi = 300,
  rasterize_dev = "cairo"
)

Arguments

plot

A plotit object

xintercept

x-intercept for vertical line(s)

yintercept

y-intercept for horizontal line(s)

slope

Line slope for abline

intercept

Line intercept for abline

x

Start x coordinate(s) for segment

xend

End x coordinate(s) for segment

y

Start y coordinate(s) for segment

yend

End y coordinate(s) for segment

colour

Line colour

linetype

Line type

linewidth

Line width in mm

...

Other arguments passed to the underlying geom

rasterize

If TRUE, rasterize via ggrastr::rasterise().

rasterize_dpi

DPI for rasterization (default 300).

rasterize_dev

Graphics device for rasterization (default "cairo").

Value

Modified plotit object

Details

Dispatch priority: vline/hline > abline > segment.

References

Vega-Lite: Rule

AntV G2: LineX / LineY / Range

Examples

plotit(iris, encode(x = Sepal.Width, y = Sepal.Length)) |>
  mark_rule(xintercept = 3, colour = "red", linetype = "dashed")