因此,我正在使用该数据集以及美国南部的数据。我的部分工作是用底图映射空间分布。指示我使用tmap函数。
因此,我的choropleth映射可以通过以下代码很好地显示出来:
library(tidyverse)
library(sf)
library(tmap)
library(RColorBrewer)
south <- st_read("south.shp")
tm_shape(south) +
tm_fill("HR90",title="Homicide Rate per 100,000", palette = "BuPu", style="quantile", legend.hist=TRUE) +
tm_borders() +
tm_layout(legend.outside = TRUE, legend.outside.position = "right", main.title = "Homicide Rate in Southern US Counties, 1990", title.size = 1.5,main.title.position="center")
但是当我尝试使用以下代码添加底图时,该底图与最后一个代码块相同,但是添加了底图:
tmap_mode("view")
tm_shape(south) +
tm_fill("HR90",title="Homicide Rate per 100,000", palette = "BuPu", style="quantile", legend.hist=TRUE) +
tm_borders() +
tm_layout(legend.outside = TRUE, legend.outside.position = "right", main.title = "Homicide Rate in Southern US Counties, 1990", title.size = 1.5,main.title.position="center") +
tm_basemap(server="OpenStreetMap",alpha=0.5)
我得到的只是一本无颜色的香草传单。看起来就像普通的Google地图,但我的Choropleth地图没有颜色。可能是什么问题呢?我之前使用过其他数据,并且使用了完全相同的代码,并且底图显示的颜色也很好。谢谢。