【问题标题】:R stat_smooth all pointsR stat_smooth 所有点
【发布时间】:2012-03-19 11:57:49
【问题描述】:

来自Plot vectors of different length with ggplot2,我有我的线条情节。

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

但这会平滑一条线。如何平滑所有数据点?

【问题讨论】:

标签: r ggplot2


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

应该这样做。这里的想法是提供一种新的组美学,以便拟合平滑器基于所有数据,而不是group = label 美学。

按照@Andrie's Answer 的示例,我建议的修改是:

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

会产生:

【讨论】:

    猜你喜欢
    • 2017-05-06
    • 2020-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多