11

下面是一个相关的例子。我正在将投篮效率视为 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)

在此处输入图像描述

4

2 回答 2

19

如上所述,如果您将第一行更改为

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

有用。

这是一个更正的版本:

在此处输入图像描述

于 2012-12-16T20:05:38.080 回答
0

当您想要多条平滑线时,您可以分别在每个图表中进行加权:

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))
于 2018-06-21T21:17:13.830 回答