我正在从两个不同的数据库中绘制以下线图:
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")
图表很好,但是,我试图命名两条彩色线条(多年,一条是2015年,另一条是2016年),但我似乎无法让它发挥作用。
感谢您的帮助。