Skip to content

Alignment difficulties with theme(strip.placement = "outside") #446

Open

Description

@davidhodge931

Likewise strip.placement.x and strip.placement.y

library(patchwork)
library(tidyverse)

set_theme(theme_classic() + theme(strip.placement = "outside"))

p1 <- ggplot(mtcars) + geom_point(aes(mpg, disp))
p2 <- ggplot(mtcars) + geom_boxplot(aes(gear, disp, group = gear))
p3 <- ggplot(mtcars) + geom_bar(aes(gear)) + facet_wrap(~cyl)

p1 / (p3 | p2)

Image

Created on 2025-08-26 with reprex v2.1.1

Activity

  1. Yunuuuu commented on Oct 22, 2025

    @Yunuuuu

    I’ve developed a new approach in the ggalign package for plot alignment that can handle different strip placements, as demonstrated below:

    library(ggalign)
    p0 <- ggplot(mpg, aes(displ, hwy)) +
      geom_point() +
      facet_wrap(~"foo", strip.position = "bottom") +
      theme(strip.placement = "inside", strip.text = element_text(size = 20))
    p1 <- p0 + theme(strip.placement = "outside")
    alignpatches(p0, p1)
    Image

    I apologize that it is not feasible to integrate this directly into the patchwork package, as it would require significant refactoring of existing code—something that was previously declined in issue #379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions