Home

Awesome

matplotsoccer

This is a package to visualize soccer data

To install it simply

pip install matplotsoccer

1. Plotting a 105 x 68 soccer field with matplotsoccer.field():

You can also:

matplotsoccer.field("green",figsize=8, show=False)
plt.scatter(x,y)
plt.axis("on")
plt.show()

2. Plotting a heatmap with matplotsoccer.heatmap()

hm = matplotsoccer.count(x,y,n=25,m=25) # Construct a 25x25 heatmap from x,y-coordinates
hm = scipy.ndimage.gaussian_filter(hm,1) # blur the heatmap
matplotsoccer.heatmap(hm) # plot the heatmap

The most important parameters are:

matplotsoccer.heatmap(hm,cmap="hot",linecolor="white",cbar=True)

3. Plotting soccer event stream data with matplotsoccer.actions()

Here is an example of five actions in the SPADL format (see https://github.com/ML-KULeuven/socceraction) leading up to Belgium's second goal against England in the third place play-off in the 2018 FIFA world cup.

game_idperiod_idsecondsteamplayerstart_xstart_yend_xend_yactiontyperesultbodypart
865722179BelgiumAxel Witsel37.144.853.848.2passsuccessfoot
865722181BelgiumKevin De Bruyne53.848.270.642.2dribblesuccessfoot
865722184BelgiumKevin De Bruyne70.642.287.449.1passsuccessfoot
865722185BelgiumEden Hazard87.449.197.938.7dribblesuccessfoot
865722187BelgiumEden Hazard97.938.710537.4shotsuccessfoot

Here is the phase visualized using matplotsoccer.actions()

matplotsoccer.actions(
    location=actions[["start_x", "start_y", "end_x", "end_y"]],
    action_type=actions.type_name,
    team=actions.team_name,
    result= actions.result_name == "success",
    label=actions[["time_seconds", "type_name", "player_name", "team_name"]],
    labeltitle=["time","actiontype","player","team"],
    zoom=False
)

(c) Tom Decroos 2019