I cannot figure out how to manually set up a legend for this plot. I just want to make dot, dashed, line color legend.
The current code looks like this:
x1 <- data[[paste(event_list[i],"_1",sep="")]]
x2 <- data[[paste(event_list[i],"_2",sep="")]]
x3 <- data[[paste(event_list[i],"_3",sep="")]]
x = (x1 + x2 + x2)/ 3
y <- data[[paste(event_list[i],"_AI",sep="")]]
df <- data.frame(x,y)
fit <- deming(x ~ y,data = df)
ggplot(data.frame(x, y), aes(x = x, y = y)) +
geom_point() +
geom_abline(intercept = 0, slope = 1, color = "black", linetype = "dashed") +
geom_abline(intercept = fit$coefficients[1], slope = fit$coefficients[2], color = "red") +
geom_abline(intercept = fit$ci[3], slope = fit$ci[4], color = "blue", linetype = "dashed") +
geom_abline(intercept = fit$ci[1], slope = fit$ci[2], color = "blue", linetype = "dashed") +
scale_color_manual(name = "Linear Regression", values = c("black", "red", "blue"), labels = c("Identity Line", "Deming Coef", "Confidence Interval")) +
scale_linetype_manual(name = "Linear Regression", values = c("dashed", "solid", "dashed"), labels = c("Identity Line", "Deming Coef", "Confidence Interval")) +
labs(x = "X", y = "Y")+
ggtitle(paste(event_list[i],"Deming Regression")) +
xlab("Variables") +
ylab("Reference")