You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is similar to an old issue #219 , but a bit long time ago. So I hope it is OK for me to open a new one.
I used brewer.pal from RColorBrewer package to prepare the col.regions with 5 groups. However, the region colors look different from the ones on the legend.
I think this has something to do with alpha.regions in the first output, but not sure why leaflet would be more similar here.
colRegions <- colorRampPalette(brewer.pal(5, 'YlOrRd'))
b <- mapview(sa3, zcol = "AREASQKM16",
at = quantile(sa3$AREASQKM16, prob = seq(0, 1, length.out=6)),
color = NA, map.types = "OpenStreetMap",
layer.name = "Area in km^20",
col.regions = colRegions)
The region colors are more similar to the one with addLegend if I clear the legend control and add legend with leaflet function.
colPal <- colorQuantile("YlOrRd", n = 5, domain = sa3$AREASQKM16)
b@map %>% clearControls() %>% addLegend(position = "topright",
pal = colPal, title = "Area in km^2",
values = sa3$AREASQKM16,
labFormat = function(type, cuts, p) {
n = length(cuts)
paste0(cuts[-n], " – ", cuts[-1])
})
The text was updated successfully, but these errors were encountered:
Yeah, that's a tricky one and there is no clear solution here. The legend colors have a alpha of 1 whereas the the polygons are filled with an alpha of 0.6 by default (I think). The colors in the legend can only ever match the ones on the map if both are completely opaque. Otherwise their values will depend on what's behind them, i.e. the location on the map...
That said, there was a bug I recently addressed which would lead to these fully opaque legends. When you re-install from here, you can control legend.opacity via the options.
This is similar to an old issue #219 , but a bit long time ago. So I hope it is OK for me to open a new one.
I used
brewer.pal
fromRColorBrewer
package to prepare thecol.regions
with 5 groups. However, the region colors look different from the ones on the legend.I think this has something to do with
alpha.regions
in the first output, but not sure whyleaflet
would be more similar here.The region colors are more similar to the one with
addLegend
if I clear the legend control and add legend withleaflet
function.The text was updated successfully, but these errors were encountered: