将 colorFactor 调色板添加到 mapview 对象
add colorFactor palette to mapview object
目的是为因子值提供固定颜色。我很难将 colorFactor 比例应用于 mapview 对象。但是,调色板似乎与 zcol 不匹配。
我尝试了以下,类似于传单地图。
library(mapview)
colors <- colorFactor(palette = c("Red", "Green", "Blue"),
levels = c("Oberfranken","Mittelfranken", "Unterfranken"))
mapview(franconia, zcol = "district",col.regions=colors)
我收到以下错误消息:
1: In col.regions(nregions) : Some values were outside the color
scale and will be treated as NA
有什么帮助吗?
以下内容适用于传单,但不使用 mapview。
franconia %>% leaflet() %>% addTiles() %>% addPolygons(fillColor = ~colors(district))
mapview::mapviewColors 似乎可以解决问题:
library(mapview)
colors <- mapviewColors(x=franconia,
zcol = "district",
colors = c("Red", "Green", "Blue"),
at = c("Oberfranken","Mittelfranken", "Unterfranken"))
mapview(franconia, zcol = "district",col.regions = colors)
目的是为因子值提供固定颜色。我很难将 colorFactor 比例应用于 mapview 对象。但是,调色板似乎与 zcol 不匹配。
我尝试了以下,类似于传单地图。
library(mapview)
colors <- colorFactor(palette = c("Red", "Green", "Blue"),
levels = c("Oberfranken","Mittelfranken", "Unterfranken"))
mapview(franconia, zcol = "district",col.regions=colors)
我收到以下错误消息:
1: In col.regions(nregions) : Some values were outside the color
scale and will be treated as NA
有什么帮助吗?
以下内容适用于传单,但不使用 mapview。
franconia %>% leaflet() %>% addTiles() %>% addPolygons(fillColor = ~colors(district))
mapview::mapviewColors 似乎可以解决问题:
library(mapview)
colors <- mapviewColors(x=franconia,
zcol = "district",
colors = c("Red", "Green", "Blue"),
at = c("Oberfranken","Mittelfranken", "Unterfranken"))
mapview(franconia, zcol = "district",col.regions = colors)