I have two datasets which I plot one above the other. I want to use different manual color ramps for them. However, scale_color_manual changes color for both data sets at the same time.
set.seed(123)
data1 <- data.frame(x=rnorm(25,2,.5),y=rnorm(25,2,1),z=factor(sample(c(1:3),25,replace=TRUE)))
data2 <- data.frame(x=rnorm(25,4,1),y=rnorm(25,2,.5),z=factor(sample(c(1:3),25,replace=TRUE)))
col1 <- c("lightblue","blue","darkblue") #corresponding to levels of 1...3 in data1
col2 <- c("lightgreen","green","darkgreen") #corresponding to levels of 1...3 in data2
ggplot(mapping=aes(x=x,y=y,color=z,size=5)) +
geom_point(data=data1) +
scale_color_manual(values=col1)+
geom_point(data=data2) +
scale_color_manual(values=col2)
Actual results area all in green. However, points more to the left should be in blue.