rstudio / leaflet

R Interface to Leaflet Maps
http://rstudio.github.io/leaflet/
Other
805 stars 508 forks source link

feat: Expand available `{viridis}` palettes in `colorNumeric()` #924

Closed jack-davison closed 2 months ago

jack-davison commented 2 months ago

Since #897 {leaflet} uses {viridisLite}.

colorNumeric() only allows users to easily use four of the eight palettes available through {viridisLite}.

This PR allows the other four - turbo, mako, cividis, and rocket.

Slightly selfish PR in that I do like "turbo" for a not totally dreadful rainbow palette! Also I can't see a reason why only four of the eight palettes should be allowed / documented.

Minimal reproducible example

devtools::load_all()
#> ℹ Loading leaflet

pal <- colorNumeric("turbo", breweries91$founded)

leaflet(breweries91) |>
  addTiles() |>
  addCircleMarkers(color = ~ pal(founded)) |>
  addLegend(pal = pal,
            values = breweries91$founded)

Created on 2024-07-25 with reprex v2.1.0

PR task list:

No current tests for different viridisLite palettes, so no tests added.

schloerke commented 2 months ago

Thank you!