我使用ggplot为R中的两个变量做了一个散点图:
ggplot(analizaDate, aes(stima, reusita)) +
geom_point() + xlab('Stima de sine') + ylab('Reușita școlară') + labs(title="Diagrama împrăștierii") +
geom_smooth(method = "lm", se = FALSE)
如何以两种不同的颜色制作这两个变量以及如何为它们添加图例?
我的数据:
analizaDate <- structure(list(Stima.de.sine = c(11, 17, 17, 17, 14, 17, 17,
17, 17, 17, 16, 14, 17, 17, 21, 17, 17, 17, 12, 17, 17, 17, 13,
17, 16, 17, 12, 17, 19, 17, 17, 17, 17, 11, 17, 17, 17, 19, 17,
17, 17, 17, 17, 17, 10, 17, 15, 17, 17, 17, 17, 17, 16, 11, 17,
17, 14, 17, 19, 17, 17, 11, 17, 17, 15, 17, 17, 17, 18, 17, 17
), Reușita.școlară = c(45, 83, 89, 79, 37, 76, 57, 85, 82,
66, 14, 43, 76, 53, 86, 73, 69, 90, 10, 116, 99, 78, 31, 72,
39, 65, 9, 58, 89, 63, 79, 92, 109, 28, 91, 67, 74, 107, 76,
90, 99, 88, 84, 104, 53, 61, 10, 84, 73, 89, 93, 75, 49, 41,
64, 91, 45, 53, 109, 65, 101, 48, 85, 88, 46, 98, 75, 89, 72,
61, 74)), .Names = c("Stima.de.sine", "Reușita.școlară"), class = "data.frame", row.names = c(NA,
-71L))