Bug in geom_path when alpha used

89 views
Skip to first unread message

Karl Ove Hufthammer

unread,
Sep 24, 2009, 6:37:58 AM9/24/09
to ggp...@googlegroups.com
I found a bug in geom_path when alpha is used. It looks like the alpha
value only works correctly when the colour is set to the same value.
Here's a simple example:

n=10
x=rnorm(n)
y=rnorm(n)
z=seq(n)
w=sample(c("A","B"),10,replace=TRUE)

# This works.
qplot(x,y,colour=z,geom="path",size=I(2))

# This does not (all the line segments have the same alpha value).
qplot(x,y,alpha=z,geom="path",size=I(2))

# This does seem to work, though.
qplot(x,y,alpha=z,colour=z,geom="path",size=I(2))

# And this does not.
qplot(x,y,alpha=z,colour=w,geom="path",size=I(2))

--
Karl Ove Hufthammer

baptiste auguie

unread,
Sep 24, 2009, 7:37:52 AM9/24/09
to Karl Ove Hufthammer, ggp...@googlegroups.com
Hi,

Confirmed here, it looks as though the last line below is the problem
in geom-path-.r,

# Work out whether we should use lines or segments
attr <- ddply(munched, .(group), function(df) {
data.frame(
solid = identical(unique(df$linetype), 1),
constant = nrow(unique(df[, c("colour","size", "linetype")])) == 1

i.e., it doesn't check for varying alpha and decides to use lines
instead of segments (I guess).

baptiste
--
_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

http://newton.ex.ac.uk/research/emag
______________________________

hadley wickham

unread,
Sep 25, 2009, 11:55:29 AM9/25/09
to baptiste auguie, Karl Ove Hufthammer, ggp...@googlegroups.com
Thanks for the bug report and fix - it's now corrected in the
development version.
Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages