Skip to contents

linear_gradient() and radial_gradient() are vellum::linear_gradient() and vellum::radial_gradient(), re-exported. 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. A gradient cannot be mapped to a data column (it is one paint per region).

Details

Both take colours and optional stops. A linear gradient's x1/y1/x2/y2 (in units, "npc" by default) set its direction; a radial gradient takes cx/cy/r plus the optional focal circle fx/fy/fr. Both also take extend and interpolation ("srgb" default, or "oklab" / "oklch" to blend the stops perceptually — "oklch" additionally preserves chroma by rotating hue). Each returns a vellum_gradient object usable as a fill value. See vellum::linear_gradient() / vellum::radial_gradient() for the full reference.

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))