Remove border lines in ggplot map/choropleth

江枫思渺然 提交于 2019-12-03 05:56:20

Another option is to set both fill and color equal to group, which worked on the macOS I tried it on:

library("ggplot2")
library("maps")
tn = map_data("county", region = "tennessee")
ggplot(tn, aes(x = long, y = lat, group = group)) + 
  geom_polygon(aes(fill = group, color = group))

Output:

Setting color = NA works for me:

ggplot(tn, aes(x = long, y = lat, group = group)) + 
    geom_polygon(aes(fill = group), color = NA) +
    coord_map()

produces this plot with no spaces between polygons.

I'm using ggplot2 version 1.0.0.

I added coord_map to give it the right aspect ratio. On my machine, that doesn't affect the borders, I'm not sure why borders are visible in your second post. Here's mine:

ggplot(tn, aes(x = long, y = lat, group = group)) + 
  geom_polygon(aes(fill = group), color = NA)

I can confirm it's specific to the Mac. Was just trying to do the same and 'colors=NA' has no visible effect in R Studio on a Mac, the borders still show. Just loaded the project on Windows and the borders are gone.

For reference, my set-up: Mac is running R Studio 0.98.1074 on Mac OS X 10_10_1 (Yosemite). Windows is running R Studio 0.98.1073 on Windows 7.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!