geom_map borders in ggplot2

前端 未结 1 1157
盖世英雄少女心
盖世英雄少女心 2021-01-21 10:21

I am trying to produce a choropleth map using geom_map in ggplot2. I want to outline the various regions in black or some other color to distinguish between areas that are simil

相关标签:
1条回答
  • 2021-01-21 10:58

    You need to add the polygon borders using geom_polygon. In the code below you need to fill in the XXXX with a data set (data) and lat and long (x and y) values for each polygon. I usually get my data from the maps package, not sure if this is what you did.

    ggplot(subset(df, as.character(variable) == "value"), aes(map_id = id)) +
      geom_map(aes(fill = pct), colour = "black", map = ggmap) +
      geom_polygon(data=XXXX, aes(x=XXXX, y=XXXX), colour='black', fill=NA) +
      expand_limits(x = ggmap$long, y = ggmap$lat) +
      scale_fill_gradient(low = "antiquewhite", high = "darkred") +
      opts(title = "Title", panel.background = theme_rect(fill = "grey90"))
    
    0 讨论(0)
提交回复
热议问题