My data consists of three variables:volume, occ and state. I want to have a volume-occ path & point plot with the paths and points marked by different colours according to the state.
Here is my code:
qplot(occ,volume,data = data,geom=c('path','point'),color=factor(state))+scale_colour_manual(values=c("blue", "orange", "red"))
qplot(occ,volume,data = data,geom=c('path','point'))
If you set the color to a variable the data are also grouped by this variable. To prevent this set the group attribute manually to a constant. Here is an example:
df <- data.frame(x = 1:20, y = c(rnorm(10, 5, 2), rnorm(10, 5, 2)), group = c(rep("a", 10), rep("b", 10) )) ggplot(df, aes(x = x, y = y, group = 1, col = group))+ geom_path()
The same with qplot:
qplot(x,y,data = df,geom=c('point'),color=factor(group), group = 1)
So just add
group = 1 to your code and it will work the way you expect it.