我希望能够构建一些图表来展示一些NBA球员和球队的投篮趋势/效果.我想如下格式化六边形:尺寸将代表镜头的数量,颜色将代表该位置的相对效率(pts/attempt).这是我正在寻找的一个很好的例子,由Kirk Goldsberry创建:

我已经能够使用hexbins并hexTapply获得接近期望结果的东西,但形状是圆形.这是我的代码(包括示例数据):
library(hexbin); library(ggplot2)
df <- read.table(text="xCoord yCoord pts
11.4 14.9 2
2.6 1.1 0
4.8 4.1 2
-14.4 8.2 2
4.2 0.3 0
0.4 0.0 2
-23.2 -1.1 3", header=TRUE)
h <- hexbin (x=df$xCoord, y = df$yCoord, IDs = TRUE, xbins=50)
pts.binned <- hexTapply (h, df$pts, FUN=mean)
df.binned <- data.frame (xCoord = h@xcm,
yCoord = h@ycm, FGA = h@count, pts = pts.binned)
chart.player <- ggplot (df.binned, aes (x =xCoord , …Run Code Online (Sandbox Code Playgroud)