Code
using Images
import CairoMakie:Axis
include("utils.jl")
[ Info: loading success
using Images
import CairoMakie:Axis
include("utils.jl")
[ Info: loading success
= load("./imgs/halfcourt.png")
img = range(-250.0, 250.0, length=size(img,1))
xs = range(-50.0,420.0, length=size(img,2)) ys
-50.0:0.37630104083266613:420.0
=@pipe CSV.File("./data/nba_shot.csv")|>DataFrame|>dropmissing|>Float64.(_)
df=coerce(df.shot, Multiclass)
df.shotfirst(df,10)
Row | x | y | shot |
---|---|---|---|
Float64 | Float64 | Cat… | |
1 | 95.0 | 242.0 | 1.0 |
2 | 129.0 | 43.0 | 0.0 |
3 | 20.0 | 10.0 | 0.0 |
4 | -127.0 | 239.0 | 0.0 |
5 | -13.0 | 14.0 | 1.0 |
6 | 30.0 | 252.0 | 1.0 |
7 | 168.0 | 208.0 | 0.0 |
8 | 130.0 | 17.0 | 1.0 |
9 | 9.0 | 21.0 | 0.0 |
10 | -2.0 | 264.0 | 0.0 |
using GLMakie
=Figure()
fig=Axis(fig[1,1])
aximage!(ax,rotl90(img))
GLMakie.
= AlgebraOfGraphics.data(df) * mapping(:x, :y,color=:shot)
plt draw!(fig[1,1],plt * visual(Scatter))
fig
set_aog_theme!()
= (width = 150, height = 150)
axis = AlgebraOfGraphics.data(df) * frequency() * mapping(:shot)
shot_frequency draw(shot_frequency; axis)
let
= (type = Axis3, width =600, height = 600)
axis = AlgebraOfGraphics.density() * visual(Wireframe, linewidth=0.05)
layer = AlgebraOfGraphics.data(df)* layer* mapping(:x,:y)
plt draw(plt; axis)
end