-
Notifications
You must be signed in to change notification settings - Fork 504
Open
Description
Consider this 'binary' palette function:
library(leaflet)
# Example data
df <- data.frame(
lat = c(40.7, 34.0, 41.9),
lng = c(-74.0, -118.2, 12.5),
value = c(10, 20, 30)
)
pfun = function(x) {
ifelse(x < 0.5, "blue", "red")
}
pal = colorNumeric(palette = pfun,
domain = df$value)
When feed into addLegend
, it seems to 'bleed' colors:
leaflet(df) %>%
addTiles() %>%
addCircleMarkers(
~lng, ~lat,
color = ~pal(value),
radius = 8,
fillOpacity = 0.8
) %>%
addLegend(
"bottomright",
pal = pal,
values = ~value,
title = "Value",
labFormat = labelFormat(suffix = ""),
opacity = 1
)

I was expecting a hard distinction between blue and red in the middle of the value range. Is this a bug, or am I missing something? Triggered by r-tmap/tmap#1175 (comment)
Metadata
Metadata
Assignees
Labels
No labels