R stat_smooth所有点 [英] R stat_smooth all points
本文介绍了R stat_smooth所有点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ggplot(plotData,aes(x,y,label = label,group) = label))+ geom_line()+ stat_smooth()
但是这会平滑每行一行。如何平滑所有数据点?
解决方案
ggplot(plotData,aes(x ,y,label = label,group = label))+
geom_line()+
geom_smooth(aes(group = 1))
应该这样做。这里的想法是提供一个新的团体美学,以便适合的平滑器基于所有数据,而不是 group = label
审美。
以 @ Andrie的答案为例,我提出的修改是:
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所有点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文