How to weight smoothing by arbitrary factor in ggplot2?

后端 未结 2 1390
醉梦人生
醉梦人生 2021-01-12 14:30

The following is a relevant example. I\'m looking at shot efficiency as a function of distance for NBA players. I want to weight the smoothing by the volume of shots taken a

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 15:23

    When you want to have multiple smooth lines you could do the weighting in each graph separately:

    ggplot(top10,aes(x=FT,y=PPS,size=FGA,color=PPS))
    +scale_x_continuous(limits = c(0, 30))
    +scale_y_continuous(limits = c(0, 2.2))+geom_point()
    +facet_grid(NAME~.,space="free")
    +stat_smooth(color="darkblue",size=2, aes(weight= FGA))
    

提交回复
热议问题