使用choroplethr为阿拉斯加和夏威夷设置背景

时间:2016-08-30 09:49:06

标签: r ggplot2 maps choropleth choroplethr

我正在使用choroplethr包来创建热图,但我无法为阿拉斯加和夏威夷设置不透明度。 enter image description here

代码:

  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")

0 个答案:

没有答案