How is weight smoothing an arbitrary factor in ggplot2?

The following is an example. I look at shot efficiency as a function of distance for NBA players. I want to weigh the smoothing by the volume of shots fired at each distance (i.e. the size of the bubbles). Is there any way to do this? The command to create this graph is:

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) 

enter image description here

+4
source share
1 answer

As Ben noted, if you change the first line to

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

it works.

Here's the adjusted version:

enter image description here

+10
source

All Articles