I want to use patterns (stripes, etc) in a county map of Nebraska to distinguish between the counties, rather than colors. The code below works, but I can't get the lines to just be nice, simple, solid lines. They always show up as these thick lines with borders, which is ugly. How do I get my patterns to just be simple lines, at different angles, with some dashed and some solid? The documentation for the ggpattern package is nothing but confusing for me.
ggplot(ne_counties_dataframe) + geom_sf(data = ne_counties_dataframe, color = 'black', lwd = 0.5) +
geom_sf_pattern(aes(pattern = Both, pattern_color = 'white', pattern_fill = Both, pattern_density = 0.1))
"Both" is a column that contains 3 factors, 'Both', 'Neither', and 'Low_Income'. I want the patterns to vary by this column. Thank you.
One option is to map pattern_angle
to, say, county name. You can make the pattern fill gray, turn off the pattern color, and decrease the pattern scale to make it smaller:
library(tidyverse)
library(tigris)
library(ggpattern)
library(sf)
ne_counties_dataframe <- counties("Nebraska")
ggplot(ne_counties_dataframe) +
geom_sf(data = ne_counties_dataframe, color = 'black', lwd = 0.5) +
geom_sf_pattern(aes(pattern_angle = NAME), pattern = "stripe",
pattern_fill = "gray50", pattern_colour = NA,
pattern_spacing = 0.02, fill = "white") +
theme_minimal(base_size = 16) +
theme(legend.position = "none") +
ggtitle("Counties of Nebraska")