我知道this和this的帖子。然而,当我尝试以下操作时,似乎没有得到预期的结果:数据可以直接从here加载。这个想法是,在一个完全虚构的数据集中,几个运动员在不同比赛完成后血液中的葡萄糖水平将取决于一些虚构的氨基酸(AAA)。 该图的调用为: ggplot(df, aes(x = AAA, y = glucose, color=athletes)) + geom_point() + geom_smooth(method="lm", fill=NA) 我希望每个运动员都有不同的线条,而不是一条回归线。我的想法是得到类似于this的东西。
像这样的内容吗? ggplot(df, aes(x = AAA, y = glucose, color=athletes, group=athletes)) + geom_point() + geom_smooth(method="lm", fill=NA) 或者你可能更喜欢这个 ggplot(df, aes(x = AAA, y = glucose, color=as.factor(athletes), group=as.factor(athletes))) + geom_point() + geom_smooth(method="lm", fill=NA)