简体   繁体   English

如何在 R 中手动更改 tmap 中的连续比例颜色

[英]how to manually change continuous scale color in tmap in R

How can I manually determine the colors on a continuous scale in tmap?如何在 tmap 中以连续比例手动确定 colors?

For example, I am working with a map similar to the one below:例如,我正在使用类似于下面的 map:

data(World)
World$gdp_cap_est2 <- World$gdp_cap_est -100000
tm_shape(World) + tm_polygons(col="gdp_cap_est2",
                              style = "cont")
                                       

I'd like the color to be red for negative values, I'd like the color to be white at and around zero, and I'd like the color to be blue for positive values.我希望颜色为红色以表示负值,我希望颜色为白色且接近零,我希望颜色为蓝色以表示正值。

在此处输入图像描述

Thank you so much for the help!非常感谢你的帮助!

Use tmaptools::palette_explorer() to find the correct palette.使用tmaptools::palette_explorer()找到正确的调色板。

palette = "RdBu" is the most appropriate. palette = "RdBu"是最合适的。

data(World)
World$gdp_cap_est2 <- World$gdp_cap_est -100000
tm_shape(World) + tm_polygons(col="gdp_cap_est2",
                              style = "cont",
                              palette = "RdBu")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM