Remove grid, background color, and top and right borders from ggplot2

后端 未结 7 1542
生来不讨喜
生来不讨喜 2020-11-29 16:31

I would like to reproduce the plot immediately below by using ggplot2. I can come close, but cannot remove the top and right borders. Below I present several attempts usin

7条回答
  •  情书的邮戳
    2020-11-29 16:42

    The above options do not work for maps created with sf and geom_sf(). Hence, I want to add the relevant ndiscr parameter here. This will create a nice clean map showing only the features.

    library(sf)
    library(ggplot2)
    
    ggplot() + 
      geom_sf(data = some_shp) + 
      theme_minimal() +                     # white background
      theme(axis.text = element_blank(),    # remove geographic coordinates
            axis.ticks = element_blank()) + # remove ticks
      coord_sf(ndiscr = 0)                  # remove grid in the background
    

提交回复
热议问题