Skip to content

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Mar 28, 2024

This PR aims to fix #4852.

Briefly, draw_key_polygon() used to cap the linewidth aesthetic to some portion of the key size. Now that we can let the grobs contribute to key sizes, it is more straightforward to use that mechanism than have the legend display incorrect linewidths.

A reprex similar to the one in the issue:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

exp_df <- data.frame(x = letters[1:3], size = c(1, 4, 16))
ggplot(exp_df, aes(x, 1L, linewidth = size)) +
  geom_col(colour = "black", fill = "transparent") +
  scale_linewidth_identity(guide = "legend")

Created on 2024-03-28 with reprex v2.1.0

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand teunbrand merged commit 89b829d into tidyverse:main May 20, 2024
@teunbrand teunbrand deleted the draw_key_polygon_linewiddth branch May 20, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Legend for geom_col()'s size does not correctly depict change in size
2 participants