Skip to content

null unit legend key size failed #6487

@Yunuuuu

Description

@Yunuuuu
library(ggplot2)
library(patchwork)
p1 <- ggplot(mtcars) +
  geom_point(aes(mpg, disp)) +
  ggtitle("Plot 1")

p3 <- ggplot(mtcars) +
  geom_point(aes(hp, wt, colour = mpg)) +
  ggtitle("Plot 3")
p <- patchwork::wrap_plots(
  p1, p3 + scale_color_continuous(guide = guide_colorbar(
    theme = theme(legend.key.height = unit(1, "null"))
  )),
  ncol = 1L,
  guides = "collect"
)
print(p)
#> Error: Cannot create zero-length unit vector ("unit" subsetting)

Created on 2025-05-30 with reprex v2.1.0
~
~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions