Removing outside border line in R map
12:29 01 Dec 2025

I am working on highlighting groups of counties within Ohio and while I am happy with where I have ended up overall, I have one aesthetic issue I cannot seem to solve (and it may not be solvable).

Goal: Map of Ohio with grouped counties filled white with red border around group (no internal red border in group, but with county borders) and ungrouped counties in gray.

Here's a clip of what the issue looks like on a corner of my full map. I am trying to get rid of that extra border that is outside of the border of Ohio on groups of counties. The red line inside the groups of counties is great and it doesn't have the outside border problem with the grayed-out counties because I put the "nogroup" filled counties after the others in the code. Based on that, I initially thought it was an order of operations issue in the ggplot() code, but I tried multiple permutations to no avail.

I'll give a smaller dataset below to replicate the issue, but it's worth noting that I actually have 25 groups of counties and therefore filling the groups with different colors doesn't work because you wouldn't be able to get enough colors that can easily be differentiated (Unless someone has code that allocates colors to polygons based on contrast with adjacent colors? Then you could use a more limited palette and repeat colors across the geographic area...).

# Load relevant packages
library(pacman)
pacman::p_load(tidyverse, ggplot2, tigris, maps, mapdata, sf)

# Pull state and county data
OHstate <- states(cb = TRUE, class = "sf") %>% filter(NAME == "Ohio")
OHcounties <- counties(state="OH", cb=TRUE, class ="sf")

# Make groups
group1 <- OHcounties %>% filter(GEOID %in% c(39055, 39085, 39007))
group2 <- OHcounties %>% filter(GEOID %in% c(39103, 39153))
nogroup <-  OHcounties %>% filter(GEOID %in% c(39129, 39073, 39141, 39047, 39065, 39091, 39139, 39029, 39151, 39035, 39093, 39033, 39175, 39161, 39075, 39009, 39087, 39001, 39135))

# Map groups
map <- ggplot() +
  geom_sf(data = st_union(group1), color = "#C12637", linewidth = 3, fill = "white") +
  geom_sf(data = st_union(group2), color = "#C12637", linewidth = 3, fill = "white") +
  geom_sf(data = OHcounties, color = "black", fill = NA) + 
  geom_sf(data = nogroup) +
  geom_sf(data = OHstate, color = "black", linewidth = 1, fill = NA) +
  scale_fill_identity() +
  theme_void()

map 

Thanks in advance for any insight or help you can provide!

r ggplot2 mapping maps