Consider this use case, where I plot a series over rectangles which represent a binary response
d <- data.frame(x=1:50, y=runif(50), z=rep(c(T,F,T,T,F), each=10))
ggplot(d) + geom_rect(aes(xmin=x-0.5, xmax=x+0.5, ymin=-Inf, ymax=Inf, fill=z)) + geom_path(aes(x=x, y=y))
Rather than the color, I would prefer to have "something" when z is TRUE et nothing when z is FALSE (simpler, clearer, etc.). So:
ggplot(d) + geom_rect(aes(xmin=x-0.5, xmax=x+0.5, ymin=-Inf, ymax=Inf, alpha=z)) + geom_path(aes(x=x, y=y))
but then I have no way of knowing which is which because there is no legend... So I did:
ggplot(d) + geom_rect(aes(xmin=x-0.5, xmax=x+0.5, ymin=-Inf, ymax=Inf, fill=z, alpha=z)) + geom_path(aes(x=x, y=y))
But even then, the legend does not reflect the transparency of the FALSE parts.
Consider this use case, where I plot a series over rectangles which represent a binary response
Rather than the color, I would prefer to have "something" when z is TRUE et nothing when z is FALSE (simpler, clearer, etc.). So:
but then I have no way of knowing which is which because there is no legend... So I did:
But even then, the legend does not reflect the transparency of the FALSE parts.