I would like to plot a series of scatter points with their own color gradient to a scatter plot with an on-off color scheme. Using the mtcars dataset, best attempt is as follows:
library(ggplot2)
#Using the cars dataset. vs is intended to be on/off, qsec,mgt, and wt is intended to be continous
Data1=mtcars[1:15,c("mpg","wt","vs")]
Data1$vs=as.factor(Data1$vs)
Data2=mtcars[1:30,c("mpg","wt","qsec")]
#This works
graph=ggplot(Data1, aes(x=mpg, y=wt, colour=vs)) +
geom_point(size=2) +scale_shape_manual(values=c(19,19))+ scale_colour_brewer(palette="Set1")
#This doesn't - gives an error about needed to recieve a continuous variable. In my original dataset, this isn't a problem. This syntax doesn't work.
graph= graph + layer(data = Data2, geom="point", aes(x=mpg, y=wt, colour=qsec)) + scale_colour_gradient(low="black", high="white")
graph
I can't provide the actual data because its proprietary. But that shouldn't matter. Any help is greatly appreciated. Thank you!