Creates a horizontal colorbar as a 4-channel RGBA array. The color
strip and optional tick labels are rendered to PNG using base R
graphics (headless-safe). Returns a 3D array suitable for
image_to_array() or direct composition.
Arguments
- colormap
A vector of colors or a function returning colors (e.g.
grDevices::hcl.colors).- n_colors
Number of discrete color segments in the gradient.
- width
Output width in pixels.
- height
Output height in pixels.
- ticks
Numeric vector of tick positions in data units (matching
data_range). IfNULL, ticks are computed automatically viapretty()restricted to the data range.- tick_labels
Character vector of tick labels. If
NULL, defaults to formatted tick values.- data_range
The data range that
ticksare specified in. Defaults toc(0, 1).- label_cex
Label size multiplier.
- title
Optional title string drawn above the color strip (horizontal) or to the right (vertical).
- background
Background RGBA color (0-1 scale).