-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
When providing a plain pattern as a fixed 'fill' aesthetic, the fill is not transferred to the legend key fill.
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.
p + geom_bar(fill = list(grad))
Created on 2023-12-18 with reprex v2.0.2
The culprit seems to be the following line:
Line 233 in a4be39d
layer_params <- layer$aes_params[n == 1] |
Where only params of length 1 are included in the legend. Since a pattern is a list, it does not have length 1.
Metadata
Metadata
Assignees
Labels
No labels