Question Details

No question body available.

Tags

r ggplot2 ggpattern

Answers (1)

Accepted Answer Available
Accepted Answer
February 3, 2026 Score: 2 Rep: 34,254 Quality: High Completeness: 80%

Add group = interaction(party, consequence, lex.order = TRUE) to aes():

ggplot(df, aes(x = year, y = n, fill = party, 
               group = interaction(party, consequence, lex.order = TRUE))) +
  geomcolpattern(
    aes(pattern = factor(consequence)),
    colour = "black",
    patterncolour = "white",
    patternfill = "white",
    patterndensity = 0.3,
    patternspacing = 0.025
  ) +
  scalefillmanual(values = partycolors) +
  scalepatternmanual(values = c("0" = "none", "1" = "stripe")) +
  labs(
    x = "Year",
    y = "Count",
    fill = "Party",
    pattern = "Consequence"
  ) +
  themeclassic()

Created on 2026-02-03 with reprex v2.1.1