R包tmap中专题图如何使用连续色标?

How to use a continuous color scale for thematic maps in the R package tmap?

当我使用 tmap 制作等值线时,其中连续变量映射到填充颜色,tmap 离散化变量并按类别绘制颜色。例如,这段代码

library(tmap)
data(World)
tm_shape(World) + tm_polygons(col="gdp_cap_est")

生成一张地图,其中根据各国的人均 GDP 是否在 0-20,000 美元、20,000-40,000 美元等范围内对国家/地区进行着色。我想要一张 GDP/capita 连续映射到颜色或颜色的深浅,因此 GDP 的微小差异会导致地图上颜色的微小差异。 tmap有这个能力吗?

我们可以使用 style = contorder.

library(tmap)
data(World)

# Map the value to a continuous gradient
tm_shape(World) + 
  tm_polygons(col = "gdp_cap_est",
              style = "cont")

# Map the order to a continuous gradient
tm_shape(World) + 
  tm_polygons(col = "gdp_cap_est",
              style = "order")