alpha channel in ggplot2 does not work after insta

2019-06-18 23:27发布

问题:

after updating to R 2.15, the alpha channel in ggplot does not seem to work anymore.

plot(rnorm(100),rnorm(100),bg="#cc000055",pch=21)

works perfectly fine but

qplot(rnorm(100),rnorm(100),color="#cc000044")

does not! Also, the alpha() function from the ggplot2 package is not found anymore (I also tried ggplot2::alpha().

Is that a known problem? I wasn't able to find anything about online...

Thanks!

回答1:

I can replicate the issue using R-2.15.0 and ggplot2 0.9.0.

As Ben noted, the standard way of specifying translucency in ggplot2 is to provide an explicit alpha argument. You should try to use this for all new plotting code.

I think a case could made that ggplot should support legacy specification of alpha via the colour argument. If you feel strongly about this, then file an issue.



回答2:

This is referenced in the comments above, but if you are working with some old ggplot code and R throws an error after a call to alpha() you need to explicitly load library(scales) into your R environment.



标签: r ggplot2