tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.45k stars 2.02k forks source link

Fix `linewidth` of `draw_key_polygon()` #5815

Closed teunbrand closed 3 months ago

teunbrand commented 5 months ago

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