r - ggplot: Adding alpha value to a whole layer -
i trying plot boxplots semi-transparent. when set alpha
value, fill transparency adjusted, , not borders/strokes/colors.
any idea how make whole geom layer transparent?
library(ggplot2) ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot(aes(fill = factor(cyl), color = factor(cyl)), alpha = 0)
this won't work out of box, since polygons ggplot2
applies alpha
fill
, not colour
. in order fix that, we'll apply following ad-hoc patch taking low-level internals , adding alpha
mapping needed.
check out the following gist. won't post here, lengthy.
ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot(aes(fill = factor(cyl), color = factor(cyl)), alpha = 0.4, size = 1.4)
Comments
Post a Comment