How can I remove border lines when using geom_sf? [closed]

旧时模样 提交于 2019-12-05 02:52:19
Peter

Without a reproducible example it is difficult to know exactly what you are looking for. However, I will take a guess that your are looking for a way to suppress the lines marking boundaries between different polygons (regions), e.g., suppress the lines showing country borders on a map of the world. If that is so then here is a solution.

Use lwd = 0 in the geom_sf call.

Example (you might need to download the developmental version of ggplot2)

# devtools::install_github("tidyverse/ggplot2")
library(ggplot2)
library(maps) 
library(maptools)
library(rgeos)
library(sf)

world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE))

with_boundary <-
  ggplot() +
    geom_sf(data = world1, mapping = aes(fill = ID)) +
  theme(legend.position = "none") +
  ggtitle("With Country Boundaries")

without_boundary <-
  ggplot() +
    geom_sf(data = world1, mapping = aes(fill = ID), lwd = 0) +
  theme(legend.position = "none") +
  ggtitle("Without Country Boundaries")

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