When providing a plain pattern as a fixed 'fill' aesthetic, the fill is not transferred to the legend key fill. ``` r library(scales) library(ggplot2) packageVersion("ggplot2") #> [1] '3.4.4.9000' grad <- grid::linearGradient(pal_viridis()(10)) p <- ggplot(mpg, aes(factor(cyl), colour = "fixed")) p + geom_bar(fill = grad) ``` <!-- --> If we instead provide the pattern as a list, it works fine. ``` r p + geom_bar(fill = list(grad)) ``` <!-- --> <sup>Created on 2023-12-18 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup> The culprit seems to be the following line: https://github.com/tidyverse/ggplot2/blob/a4be39dee07010c67c31ace059b1f0a24129fc65/R/guide-legend.R#L233 Where only params of length 1 are included in the legend. Since a pattern is a list, it does not have length 1.
Activity
teunbrand commentedon Dec 18, 2023
Considered fixed by #5595.