如何重量任意因素GGPLOT2平滑?(How to weight smoothing by arbi

2019-07-05 12:29发布

下面是一个相关的例子。 我期待在射击效率的距离为NBA球员的函数。 我想加权通过在每个距离拍摄的照片的体积(气泡的即大小)的平滑化。 有没有办法做到这一点? 产生这种图的命令是:

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)

Answer 1:

作为本上面提到的,如果你改变了第一行

ggplot(top10,aes(x=FT,y=PPS,size=FGA,color=PPS,weight=FGA))

有用。

这里有一个修正的版本:



Answer 2:

如果你想有多个线条流畅,你可以做单独的每个图中的权重:

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))


文章来源: How to weight smoothing by arbitrary factor in ggplot2?
标签: r ggplot2