【发布时间】:2020-08-22 02:14:21
【问题描述】:
我使用 matplot() 将 2 个矩阵绘制成一张图,但我没有得到 ggplot 等效项。 以下是矩阵:
矩阵 A:足球比赛中的得分尝试
John Mike Luc
2010 20 30 25
2011 13 22 18
2012 10 20 14
矩阵 B:游戏数
John Mike Luc
2010 10 15 12
2011 5 8 7
2012 2 8 3
以下代码完美运行
a <- Score_Attempts
b <- Num_Of_Games
matplot(a, b, type = "l", xlab = "Score attempt", ylab = "Number of game")
legend("bottomright", legend = colnames(a), col = seq_len(a), pch = 1, cex = 0.7)
ggplot 等效项似乎有些不对劲。帮我把这个也弄好,谢谢!
data <- data.frame(ScoreAttempt = as.vector(a),
NumOfGame = as.vector(b))
ggplot(data, mapping = aes(x = ScoreAttempt, y = NumOfGame ))
labs(x="Score attempt", y= "Number of game") +
geom_line(size = 2)
【问题讨论】: