Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

alpha channel in ggplot2 does not work after installing 2.15

Tags:

r

ggplot2

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!

like image 522
user2503795 Avatar asked Apr 07 '12 09:04

user2503795


2 Answers

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.

like image 130
Richie Cotton Avatar answered Oct 13 '22 10:10

Richie Cotton


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.

like image 43
Andrew Avatar answered Oct 13 '22 11:10

Andrew