Open trevorld opened 2 years ago
Also note one can achieve a similar affect via facet_grid()
:
library(ggplot2)
library(ggpattern)
df <- transform(mpg, cyl = as.factor(cyl))
ggplot(df, aes(x = cyl)) +
facet_grid(. ~ class) +
geom_bar(aes(fill = cyl)) +
geom_bar_pattern(aes(pattern = drv),
fill = "transparent", col = "black",
pattern_spacing = 0.2, pattern_density = 0.4,
pattern_key_scale_factor = 0.2) +
scale_pattern_manual(values = c("none", "stripe", "circle"))
A new
{ggplot2}
"position" that does both a "dodge" and "stack" might be useful:Technically this seems like this should be implemented as a new
{ggplot2}
"position" class:Not necessarily useful just for
{ggpattern}
(i.e. people seem to want to do this with unpatterned basegeom_bar()
):Would
{ggpattern}
be the right level to implement this? Five years ago{ggplot2}
maintainers said they had no (near-term) plans on implementing this particular "position" themselves: https://github.com/tidyverse/ggplot2/issues/2267{ggplot2}
did add a "jitterdodge" position so perhaps "stackdodge" would be the appropriate name...