I have R-plot and I want to add a legend to this plot. Please help.
nr = 15
O <- matrix(ncol = n, nrow = nr)
for (tt in 2:nr) {
O[tt,] <- calculate_omegas(tt)
}
O_data <- as.data.frame(O)
colnames(O_data) <- c("first", "second", "third")
ggplot(O_data) + geom_point(aes(x = c(1:nr),y = first),size = 2, color = "blue") + geom_point(aes(x = c(1:nr), y = second), size = 2, color = "red") + geom_point(aes(x = c(1:nr), y = third), size = 2, color = "green") +
xlab("Length") + ylab("Proportions paid by participants") + scale_x_continuous(breaks = seq(1, nr, by = 1))