Home > Back-end >  How to completely get rid of borders in geom_sf
How to completely get rid of borders in geom_sf

Time:12-05

How can I completely get rid of borders using geom_sf? (The grids were created with st_make_grid.) I have tried color=NA and size=0, but neither do what I want.

ggplot()  
    geom_sf(data = plot_data, aes(fill = as.vector(dist)), color=NA, size=0)   
    scale_fill_viridis(discrete=FALSE, name="", direction=-1)  
    geom_sf(data = states, fill=alpha("black", 0))  
    theme_bw()

Example:

enter image description here

This relates to: enter image description here

The easiest way to fix this is, rather than trying to make the lines disappear, simply color them the same as the grid boxes.

ggplot()  
  geom_sf(data = plot_data, aes(fill = as.vector(dist),
                                color = after_scale(fill)), linewidth = 1)   
  scale_fill_viridis_c(name = "", direction=-1)  
  geom_sf(data = states, fill = alpha("black", 0), linewidth = 2)  
  theme_bw() 

enter image description here

  • Related