I am plotting the following line plot from two different databases:
ggplot() +
geom_line(data = Hour_of_accident_15, mapping = aes(x=hour_of_crash, y = n),
color = "green") +
geom_line(data = Hour_of_accident_16, mapping = aes(x=hour_of_crash, y = n),
color = "red") +
theme(plot.title = element_text(face = "bold", hjust = 0.5, size = 15)) +
scale_x_discrete(limit = 0:24,
labels = paste(c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24"))) +
labs(x = "Hours",
y="Number of car accident",
title = "Number of fatal car accident per hour")
The graph comes out fine, however, I am trying to name the two colored lines (as years, one being 2015 and the other 2016) but I cannot seem to make it work.
Thank you for your help.