How to add a legend to the plot?

Hi Everybody,
Could you help me add a legend to the plot? The code is a bit messy but I hope someone can find a solution:

plot1<-ggplot(Widerdata, aes(x = Zrelationship_length, y = Equity_recoded)) + xlim(-1,1)+ ylim(-.92,.94) + geom_abline(colour ="coral2",
intercept = b0 + -1 * narcissism, slope = relationship_length + -1 * interaction, size = 1,
fullrange = FALSE, show_guide = TRUE) + geom_abline(aes(colour = "ave. narcissism (mean)"),
intercept = b0, slope = relationship_length, size = 1, fullrange = FALSE, show_guide = TRUE) +
geom_abline(colour ="skyblue4", intercept = b0 + 1 *
narcissism, slope = relationship_length + 1 * interaction, size = 1, fullrange = FALSE, show_guide = TRUE)+
theme(
aspect.ratio = ,
axis.text = element_text(size = 8),
axis.title = element_text(size = 10),
plot.title = element_text(hjust = 0.5, size = 9, face = "bold"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
panel.border = element_blank(),
axis.line = element_line(colour ="black"),
legend.position = "none") +
labs(y = expression(atop("Partner Enhancement")),x = expression(atop("Relationship length")),title = "Study 1")

plot1+theme_bw()+scale_x_continuous(name="Relationship length", breaks=c(-1, 0, 1), labels=c("short", "average", "long"), limits=c(-.92, .94))

If you wish to have a legend why have you given it no position?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.