Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ccsarapas opened this issue May 28, 2025 · 1 comment · May be fixed by #6485 or #6488
Open

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

ccsarapas opened this issue May 28, 2025 · 1 comment · May be fixed by #6485 or #6488

Comments

@ccsarapas
Copy link

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.

@teunbrand
Copy link
Collaborator

teunbrand commented May 29, 2025

Thanks for the report! I can reproduce the issue on my end.

@teunbrand teunbrand linked a pull request May 29, 2025 that will close this issue
@teunbrand teunbrand marked this as a duplicate of #6487 May 30, 2025
@teunbrand teunbrand linked a pull request May 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants