Skip to content

legend.key.height / width don't work in dev version #6484

Closed
@ccsarapas

Description

@ccsarapas

In the current stable version, legend.key.height and legend.key.width work as expected:

packageVersion("ggplot2")
# '3.5.2'

library(ggplot2)

p <- ggplot(mpg) +
  geom_point(aes(x = factor(cyl), y = displ, color = hwy)) +
  scale_color_fermenter(palette = "RdYlBu", direction = 1) +
  theme(legend.key.width = unit(0.25, "lines"))

plots <- list(
  p + ggtitle("default"),
  p + ggtitle("0.5 lines") + theme(legend.key.height = unit(0.5, "lines")),
  p + ggtitle("2.5 lines") + theme(legend.key.height = unit(2.5, "lines")),
  p + ggtitle("null") + theme(legend.key.height = unit(1, "null"))
)

cowplot::plot_grid(plotlist = plots)

Image

But in the dev version, legend.key.height has no effect:

# in fresh session

remotes::install_github("tidyverse/ggplot2")
packageVersion("ggplot2")
# '3.5.2.9000'

library(ggplot2)

# same plotting code as above

Image

If theme(legend.direction = "horizontal"), then legend.key.height works OK but legend.key.width doesn't.

The same issue seems to affect continuous scales. Discrete scales seem to work OK but I didn't investigate extensively.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions