R stat_smooth all points

前端 未结 1 1024
悲&欢浪女
悲&欢浪女 2020-12-06 12:14

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_         


        
相关标签:
1条回答
  • 2020-12-06 12:32
    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:

    enter image description here

    0 讨论(0)
提交回复
热议问题