我正在使用choroplethr包来创建热图,但我无法为阿拉斯加和夏威夷设置不透明度。
代码:
library(ggplot2)
library(choroplethr)
library(choroplethrMaps)
data = data.frame(region=c(1001, 1003), value=c(-100,100))
choro = CountyChoropleth$new(data)
choro$ggplot_scale = scale_fill_gradient2("",
low="red",
high="green",
na.value="white")
choro$set_num_colors(1)
plot = choro$render() +
theme(
legend.background = element_rect(fill = "transparent",colour = NA),
panel.background = element_rect(fill = "transparent",colour = NA),
plot.background = element_rect(fill = "transparent",colour = NA),
strip.background = element_rect(fill = "transparent",colour = NA),
legend.key = element_rect(fill = "transparent",colour = NA)
)
ggsave(plot=plot,
filename=paste0("~/counties.png"),
bg="transparent")