Skip to contents

Thin re-exports of vellum::linear_gradient() and vellum::radial_gradient(). A gradient is an unscaled value for the fill aesthetic: pass it directly, e.g. mark_area(x = t, y = y, fill = linear_gradient(c("#00e5ff", "#00e5ff00"))), and the filled region (area / ribbon / bar) is painted with the paint as a single grob. Use "transparent" (or an "#RRGGBB00" colour) as a stop to fade out — the "glow fade under a line" look. The gradient's x1/y1/x2/y2 (in units, "npc" by default) set its direction. A gradient cannot be mapped to a data column (it is one paint per region).

Usage

linear_gradient(colours, stops = NULL, ...)

radial_gradient(colours, stops = NULL, ...)

Arguments

colours, stops

See vellum::linear_gradient() / vellum::radial_gradient().

...

Further gradient arguments passed to the vellum constructor: x1/y1/x2/y2 (linear), cx/cy/r (radial), units, and extend. See vellum::linear_gradient() / vellum::radial_gradient().

Value

A vellum_gradient object usable as a fill value.

Examples

df <- data.frame(x = 1:20, y = cumsum(abs(rnorm(20))))
vplot(df) |>
  mark_area(x = x, y = y, fill = linear_gradient(c("#00e5ff", "#00e5ff00"),
    x1 = 0, y1 = 1, x2 = 0, y2 = 0))