Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: The Alphas! They Do Nothing!

Tags:

r

ggplot2

alpha

Seriously though, I'm using ggplot2 and I believe I've tried sticking an alpha = .5 in every conceivable place to no effect whatsoever.

I would like to add transparency to the points in this graph, as they completely cover the boxplots

g <- ggplot(data=ar1yX_wnZ, aes(factor(avp), lambda))
g <- g + geom_boxplot() + geom_jitter(aes(color=rho))     
g + facet_grid(~ tau) 

I thought sticking alpha = .5 in geom_jitter would work:

g <- ggplot(data=ar1yX_wnZ, aes(factor(avp), lambda))
g <- g + geom_boxplot() + geom_jitter(aes(color=rho), alpha = .5)     
g + facet_grid(~ tau) 

But it doesn't do anything, neither does wrapping that in aes() or sticking it in the call to ggplot() or ggplot(aes()). That being said, it's not that the graph doesn't appear, or an error is produced, just that there is no transparency in the points.

This seems like the way that everybody's doing it, so I'm wondering if there's some R package that I'm missing. Any suggestions would be much appreciated. As a note, I'm using R version 2.7, and have installed ggplot2 with install.packages("ggplot2", dep=T) so I would have thought everything was there...

Edit:

For some more information/a reproducible example, this very simple case doesn't work either:

a = rnorm(10000, 0, 1)
b = rnorm(10000, 0, 1)
test = as.data.frame(cbind(a,b))
g <-ggplot(data = test, aes(a, b))
g + geom_point(alpha=.005)

I can only assume there's something wrong with my dependencies or the system I'm on (OSX).

Edit 2:

This, however, does produce transparency:

plot(a,b, main="Scatterplot Example", col=rgb(0,100,0,50,maxColorValue=255), pch=16)

Edit 3:

My session info is as follows:

> sessionInfo()
R version 2.7.1 (2008-06-23) 
i386-apple-darwin8.10.1 

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] splines   grid      stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
[1] ggplot2_0.7        plyr_0.1.1         MASS_7.2-42       
[4] RColorBrewer_1.0-2 proto_0.3-8        reshape_0.8.0     

I don't know if this could have any effect, but when I use library(ggplot2) I get the following warning messages:

Warning messages:
1: package 'ggplot2' was built under R version 2.7.2 
2: package 'RColorBrewer' was built under R version 2.7.2 
3: package 'plyr' was built under R version 2.7.2 
like image 538
Wilduck Avatar asked Feb 03 '26 13:02

Wilduck


1 Answers

You have a very old version of r which means you'll have an old version of ggplot2 which probably doesn't support alpha.

like image 139
hadley Avatar answered Feb 06 '26 03:02

hadley