ggplot really loves to draw legends only for things that have aesthetic correspondences. If you specify "code names" for colors, you can define them on a manual scale for this attribute. for instance
ggplot(df, aes(x = instance, y = total_hits))+geom_point(size = 1)+geom_line()+ geom_line(aes(x=instance, y = line1, colour="myline1")) + geom_vline(xintercept=805)+geom_line(aes(x=df$instance, y = line2, colour="myline2"))+ geom_line(aes(x=instance, y = line3, colour="myline3")) + scale_colour_manual(name="Line Color", values=c(myline1="red", myline2="blue", myline3="purple"))
should work (untested, since you haven't provided any data at all). Each time you ask a question, it is simply polite to include a reproducible example , so the answering machine does not have to do all the work on its own for testing.
source share