You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say we might want to try to adopt this in ggplot2, like so:
library(ggplot2)
ggplot(data.frame(x=1:2), aes(x, x)) +
geom_tile(aes(fill=factor(x)), width=1) +
scale_fill_manual(
values=list(grad, pat)
)
#> Error in `geom_tile()`:#> ! Problem while converting geom to grob.#> ℹ Error occurred in the 1st layer.#> Caused by error:#> ! Unknown colour name: list(x1 = 0, y1 = 0.5, x2 = 1, y2 = 0.5, stops = c(0, 1), colours = c("#DF536B", "white"), extend = "pad", group = FALSE)
As can be seen above, we currently can't use this in ggplot2. I think the only thing currently prohibiting this is the alpha() function that can't handle a list of patterns as input.
If I change the alpha() function to be like this (real solution should probably be more elegant):
alpha<-function(colour, alpha=NA) {
if (is.list(colour)) {
return(colour)
}
...# rest of function body
}
And build the package and re-load ggplot2 (which doesn't lend itself well to reprexes), I can get exactly what I might have expected:
Activity
thomasp85 commentedon Nov 1, 2023
Is this still needed in your current ggplot2 PR for pattern fills?
teunbrand commentedon Nov 1, 2023
No, this issue should be fixed by tidyverse/ggplot2#5299