相关疑难解决方法(0)

如何在R中的传单中为数值变量设置不对称颜色渐变

我想将传单调色板的中心设置为零(红白绿绿色发散)。我已经尝试了这篇文章中所说。当我尝试手动创建颜色时,出现了红色绿色发散,但无法将其居中为零。

我的密码

regions@data <- data.frame(region <- c("APAC (excl. China)", "Africa", 
                                       "Americas", "Europe", "Greater China", "Middle East"),
                           change_targeted <- c(36,-21,25,4,173,34))

color = "#666"
weight = 0.5
opacity = 1
fillOpacity = 1
dashArray = ""
hl_color = "black"
hl_weight = 1
hl_dashArray = ""

library(RColorBrewer)
nHalf = nrow(regions@data)/2
Min = min(regions@data[,"change_targeted"])
Max = max(regions@data[,"change_targeted"])
Thresh = 0

## Make vector of colors for values below threshold
rc1 = colorRampPalette(colors = c("red", "white"), space="Lab")(nHalf)    
## Make vector of …
Run Code Online (Sandbox Code Playgroud)

r color-palette leaflet shiny

4
推荐指数
1
解决办法
1637
查看次数

标签 统计

color-palette ×1

leaflet ×1

r ×1

shiny ×1