I have created a graph with ggplot2 and I would like to add a diagonal line from bottom-left to up-right and asign a color to this line. How can I do that?
ggplot(data, aes(x=DRTG, y=ORTG)) +
geom_point(colour = "#000000") +
ggtitle("Gráfico: Ratio Defensivo / Ratio Ofensivo (hasta jornada 8)") +
geom_text(label=rownames(data), colour = "#000000", nudge_x = 0, nudge_y = 0.75, size = 4, vjust = "inward", hjust = "inward", check_overlap = F) +
geom_point(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, colour="red", size = 1)) +
geom_vline(xintercept = pointMedia[, "mediaDRTG"], colour = "green") +
geom_hline(yintercept = pointMedia[, "mediaORTG"], colour = "blue") +
geom_text(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, nudge_x = 0, nudge_y = 0.75, label="Liga DIA")) +
theme(legend.position = "none")
Edit I:
I have added + geom_abline(intercept = 120, slope = 0) and I don't get anything :( What am I doing wrong?
ggplot(data, aes(x=DRTG, y=ORTG)) +
geom_point(colour = "#000000") +
ggtitle("Gráfico: Ratio Defensivo / Ratio Ofensivo (hasta jornada 8)") +
geom_text(label=rownames(data), colour = "#000000", nudge_x = 0, nudge_y = 0.75, size = 4, vjust = "inward", hjust = "inward", check_overlap = F) +
geom_point(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, colour="red", size = 1)) +
geom_vline(xintercept = pointMedia[, "mediaDRTG"], colour = "green") +
geom_hline(yintercept = pointMedia[, "mediaORTG"], colour = "blue") +
geom_text(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, label="Liga DIA"), nudge_x = 0, nudge_y = 0.75) +
geom_abline(intercept = 120, slope = 0) +
theme(legend.position = "none")
Edit II:
I have setting intercept and slope to this values and I get this pic
ggplot(data, aes(x=DRTG, y=ORTG)) +
geom_point(colour = "#000000") +
ggtitle("Gráfico: Ratio Defensivo / Ratio Ofensivo (hasta jornada 8)") +
geom_text(label=rownames(data), colour = "#000000", nudge_x = 0, nudge_y = 0.75, size = 4, vjust = "inward", hjust = "inward", check_overlap = F) +
geom_point(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, colour="red", size = 1)) +
geom_vline(xintercept = pointMedia[, "mediaDRTG"], colour = "green") +
geom_hline(yintercept = pointMedia[, "mediaORTG"], colour = "blue") +
geom_text(data=pointMedia, aes(x=mediaDRTG, y=mediaORTG, label="Liga DIA"), nudge_x = 0, nudge_y = 0.75) +
geom_abline(intercept = 11.6, slope = 1) +
theme(legend.position = "none")
And what I want is that the end of the line is in the upper right corner of the graph.
I want to draw a line from bottom left corner of the graph until upper right corner of the graph.