Skip to content

Inconsistent clipping of strip background depending on facets #5952

@teunbrand

Description

@teunbrand

When using coord_*(clip = "on") facet strips are clipped along with the panel.
When using coord_*(clip = "off"), facet_wrap() does not clip the strip, but facet_grid() does.

library(ggplot2)

# Plot with thick strip lines
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  coord_cartesian(clip = "off") +
  theme(
    strip.background = element_rect(linewidth = 5, colour = "black")
  )

# Strip is clipped
p + facet_grid(~ year)

# Strip is not clipped
p + facet_wrap(~ year)

Created on 2024-06-20 with reprex v2.1.0

I'm unsure which is the correct behaviour, but they should be consistent regardless.
Perhaps this shouldn't be under control of the Coord's clipping setting at all, but rather theme(strip.clip)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions