本文介绍了R stat_smooth所有点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从为例,我提出的修改是:

  ggplot(plotData,aes(x,y,label = label,group = label))+ 
geom_text()+
geom_smooth(aes(group = 1))

会产生:


From Plot vectors of different length with ggplot2, I've got my plot with lines.

ggplot(plotData, aes(x, y, label=label, group=label)) + geom_line() + stat_smooth()

But this smooths one line each. How do I smooth over all data points?

解决方案
ggplot(plotData, aes(x, y, label=label, group=label)) +
    geom_line() +
    geom_smooth(aes(group = 1))

should do it. The idea here is to provide a new group aesthetic so that the fitted smoother is based on all the data, not the group = label aesthetic.

Following the example from @Andrie's Answer the modification I propose would be:

ggplot(plotData, aes(x, y, label=label, group=label)) +
    geom_text() +
    geom_smooth(aes(group = 1))

which would produce:

这篇关于R stat_smooth所有点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:44