Aesthetics can be set or displayed in the ggplot call.
- Aesthetics defined in
aes(...) is displayed from the data and a legend is created. - Aesthetics can also be set to a single value, defining it outside
aes() .
In this case, it looks like you want to set alpha = 0.8 and display colour = group .
To do this,
Put alpha = 0.8 outside the definition of aes() .
g <- ggplot(df, aes(x = x, y = y, group = group)) g <- g + geom_line(aes(colour = group)) g <- g + geom_point(aes(colour = group), alpha = 0.8) g

For any displayed variable, you can suppress the legend by using guide = 'none' in the corresponding call to scale_... eg.
g2 <- ggplot(df, aes(x = x, y = y, group = group)) + geom_line(aes(colour = group)) + geom_point(aes(colour = group, alpha = 0.8)) g2 + scale_alpha(guide = 'none')
What will return an identical plot
EDIT @Joran's comment in place, I made my answer more comprehensive.
mnel Jul 30 '12 at 3:12 2012-07-30 03:12
source share