I am trying to overlay rectangles on a previous plot and cannot make
them transparent. I think I have identified the core issue below
ggplot() + geom_rect(aes(xmin=0, xmax=1, ymin=0, ymax=1), alpha=0.5)
# works
df <- data.frame(a=runif(10), b=runif(10))
ggplot(df) + geom_rect(aes(xmin=0, xmax=1, ymin=0, ymax=1), alpha=0.5)
# does not work
ggplot(df) + geom_rect(data=data.frame(x1=0, x2=1, x3=0, x4=1),
aes(xmin=x1, xmax=x2, ymin=x3, ymax=x4), alpha=0.5)
# works, but is rather cumbersome
Alpha seems to be the only aesthetic causing trouble. Changing the
color, fill, etc. works
Is that a bug or is there a reason for this behaviour?
JiHO
---
http://maururu.net
I see. I even remember someone having this issue before. Sorry for the
trouble. So I will do
ggplot() + geom_path(data=df, aes(...)) + geom_rect(xmin=0, xmax=1,
ymin=0, ymax=1, alpha=0.5)
and it will work. As in other occasions, specifying everything for
each layer is longer but more consistent. I guess I am just lazy...
PS: It seems the whole Wickham family is getting involved in ggplot!
Glad to see you here.
JiHO
---
http://maururu.net