I have a plotting function:
drawFoo <- function(df) {
ggplot(data=df, aes(x=x, y=y, colour=c)) +
geom_point(alpha=1, size=5)
}
bar <- data.frame(x=1:10, y=10:1, c=as.factor(rbinom(10, 1, 0.5)))
drawFoo(bar)
Now I'd like to use its return with slight adjustments. Say, to change colours I use
drawFoo(bar) + scale_colour_manual(values = 1:2)
However, when using the same approach to size and alpha, none of these work:
drawFoo(bar) + scale_size_manual(values = 1:10)
drawFoo(bar) + scale_alpha_manual(values = rep(1/10, 10))
and I always have the first picture unaffected.
As far as I can tell, that happens when the aesthetic in question is not mapped to a variable. But I have no idea why this is an expected behaviour, so any explanations and overriding workarounds are welcome. Thanks!