Renders a gradient with minimum and maximum ticks, from either a named color ramp or an explicit list of CSS colors. Each call adds another colorbar.
Arguments
- map
A GeoLibre widget.
- colormap
A color ramp name from
color_ramp_names(). Ignored whencolorsis supplied.- vmin
Value at the low end of the colorbar.
- vmax
Value at the high end of the colorbar.
- label
Title shown alongside the colorbar.
- units
Units suffix shown with the values.
- colors
Optional character vector of CSS colors defining a custom gradient, used instead of
colormap.- orientation
"vertical"or"horizontal".- position
Corner for the colorbar:
"top-left","top-right","bottom-left", or"bottom-right".
See also
add_legend() for categorical classes
Examples
map <- geolibre() |>
add_raster("https://example.com/dem.tif", bands = 1, colormap = "terrain") |>
add_colorbar(
colormap = "terrain", vmin = 0, vmax = 3000,
label = "Elevation", units = "m"
)