Skip to contents

Grow each non-empty pixel of a raster over a small neighbourhood so thin marks stay visible. This is datashader's spread: useful after datashade(), datashade_lines(), or datashade_segments() when the output is sparse (single-pixel lines, isolated points). dynspread() chooses the radius automatically from the image's density; spread() uses a fixed one.

Usage

spread(grob, px = 1L, shape = c("circle", "square"), how = c("over", "add"))

Arguments

grob

A raster grob (e.g. from datashade()). Other grob kinds are returned unchanged.

px

Spread radius in pixels (non-negative integer). 0 returns grob unchanged.

shape

Neighbourhood shape: "circle" (default, Euclidean radius) or "square" (Chebyshev radius).

how

How overlapping spread pixels combine: "over" (default) keeps the colour of the most-opaque contributor; "add" accumulates opacity (clamped) so overlaps darken.

Value

A raster grob with the spread applied.

Examples

set.seed(1)
g <- datashade_segments(rnorm(2000), rnorm(2000), rnorm(2000), rnorm(2000))
g2 <- spread(g, px = 2)