I am creating interaction plots in ggplot2
and keep coming up with the following error: Error: Insufficient values in manual scale. 4 needed but only 2 provided.
Code:
plot1<- data.frame(effect("current*child", outcome,
xlevels=list(child=c(-1,1))))
ggplot(plot1) + geom_line(aes(current, fit, color = child,
linetype=factor(current)), size= 1.25, )+ scale_colour_gradient(low =
"darkred", high = "darkblue") + theme_bw()+
coord_cartesian(xlim=c(-10,10), ylim=c(-10,10)) +
scale_linetype_manual(values=c("solid", "dotted"))+
theme(legend.position='none', panel.grid.major = element_blank(),
text = element_text(size=16),
panel.grid.minor = element_blank(),)+
xlab("Current")+ylab("Outcome")
I believe it has something to do with scale_color_gradient(low = "darkred", high = "darkblue")
. However, I don't know how to alter this to remove the error for an interaction plot.
Thanks!