datashader's dynspread: pick the smallest spread
radius (up to max_px) at which the shaded pixels become "connected enough" —
the fraction of non-empty pixels with a non-empty neighbour reaches threshold
— then spread() by it. Denser images spread less, sparse ones more, so a mix
of dense and sparse regions all stay legible.
Arguments
- grob
A raster grob (e.g. from
datashade()). Other grob kinds are returned unchanged.- max_px
Largest spread radius to consider (non-negative integer).
- threshold
Target fraction in
(0, 1]of non-empty pixels that should have a non-empty neighbour; growth stops once it is reached.- 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 chosen spread applied.
