I am using now version 0.9 and face a problem with the alpha() function
for scale_fill_manual: it simply does not seem to work... and the
transparency is not recognised?
See:
library(ggplot2)
library(scales)
df<-data.frame(a=1:3, b=factor(letters[1:3]))
cols<-c(alpha("red", .3),alpha("red", 0.6),alpha("red", 0.9))
plot(1:3, col=cols, cex=20, pch=19) # yes colours are different!
qplot(b,a, data=df, fill=b, geom="bar",
stat="identity")+scale_fill_manual(values = cols) #same colour?
I see the same colour for each bar... is this normal? Thanks!!
Matthieu
I couldn't get it to work nicely with qplot(), but did manage with ggplot():
df<-data.frame(a=1:3, b=factor(letters[1:3]))
ggplot(data = df, aes(x = b, y = a)) +
geom_bar(aes(alpha = b), fill = 'red', stat = 'identity') +
scale_alpha_manual(values = c(0.3, 0.6, 0.9))
Question for the gurus: Why do points get plotted with this code???
qplot(b, a, data = df) +
geom_bar(aes(alpha = b), fill = 'red', stat = 'identity') +
scale_alpha_manual(values = c(0.3, 0.6, 0.9))
Dennis
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
Thanks for your help!
So basically it seems scale_fill_manual() in 0.9 is no longer able to
support alpha levels, and these need to be specified through
scale_alpha_manual? It looks to me this should be considered a bug?
Thanks!
Matthieu
Le 30/03/2012 11:13, Dennis Murphy a �crit :
If the only thing you want to vary in a scale is alpha and that the variation maps to some of your data, then scale_alpha* is the way to go indeed.
If you want to vary both alpha and colour based on your data, mix scale_fill and scale_alpha
If you want to vary colour but have all bars be a bit transparent (with the same transparency) then *map* colour (within aes + use scale_fill) and *set* alpha (outside aes).
scale_fill* did not handle setting alpha in 0.9.0 and this was a bug; it should be fixed in the devel version.
Jean-Olivier Irisson
---
Observatoire Océanologique
Station Zoologique, B.P. 28, Chemin du Lazaret
06230 Villefranche-sur-Mer
Tel: +33 04 93 76 38 04
Mob: +33 06 21 05 19 90
http://jo.irisson.com/