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)  

enter image description here

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)  

before: enter image description here

after: enter image description here


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -