我正在创建一张鸟类物种每年百分比变化的专题地图。下面是我的代码:
tm_shape(grid83)+
tm_fill("trend", title = "Percent change per Year", textNA = "None counted", style="fixed",
breaks=c(-Inf, -1.5, -0.25, 0.25, 1.5, Inf),
palette = c("red", "orange", "yellow", "turquoise", "blue", "white"))+
tm_borders(NA)+
tm_shape(uscan83)+ # add US and CAN
tm_borders()+
tm_layout(
"Western Grebe",
legend.title.size=1,
legend.text.size = 0.6,
legend.position = c("left","bottom"),
legend.bg.color = "white",
legend.digits = 5,
legend.bg.alpha = 1)当前,所有NA值都显示为灰色。我试着改变了调色板:
palette = c("red", "orange", "yellow", "turquoise", "blue", "white"))但这似乎不起作用。NA值仍为灰色。我做错了什么?
非常感谢!
发布于 2015-10-02 03:03:23
因此,您正在尝试更改特定于NA值的颜色?tm_fill()的colorNA参数就是为了达到这个目的。
下面是一个例子:
library(tmap)
data(Europe)
tm_shape(Europe) +
tm_fill("gdp_cap_est", title = "GDP", style = "fixed",
breaks = c(0, 10000, 20000, 30000, 40000, Inf),
textNA = "Dunno",
colorNA = "green", # <-------- color for NA values
palette = c("red", "orange", "yellow", "turquoise", "blue", "white")) +
tm_borders() +
tm_layout("Wealth (or so)",
legend.title.size = 1,
legend.text.size = 0.6,
legend.position = c("left","bottom"),
legend.bg.color = "white",
legend.digits = 5,
legend.bg.alpha = 1)它看起来是这样的:

https://stackoverflow.com/questions/32890762
复制相似问题