\n",
" \n",
" \n",
" \n",
"
\n",
" \n",
"
\n",
"\n",
""
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "jDFM5Fd7FvYv",
"colab_type": "text"
},
"source": [
"The following cell plots the pitch control for a single player in a single frame -- you need to have set return_pcpp to True in the modified wide open spaces cell above to get the pitch control per player."
]
},
{
"cell_type": "code",
"metadata": {
"id": "YTh1LV_r2Vi0",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "a86dcd6c-9516-4668-9330-6f149b3a0392"
},
"source": [
"import plotly.graph_objects as go\n",
"xx = np.linspace(0,105,n_grid_points_x)\n",
"yy = np.linspace(0,68,n_grid_points_y)\n",
"\n",
"frame_to_plot = 110\n",
"player_to_plot = 18\n",
"\n",
"pl_ocean=[[0, '#ff9900'],\n",
"[0.25, '#ffcc66'],\n",
"[0.5, '#FFFFFF'],\n",
"[0.75, '#9999ff'],\n",
"[1, '#6666ff']]\n",
"\n",
"fig = go.Figure(go.Contour(x=xx, y=yy,z = pcpp[player_to_plot,frame_to_plot].reshape(n_grid_points_y,n_grid_points_x).cpu().numpy(),\n",
" colorscale = pl_ocean,\n",
" contours_coloring='heatmap',\n",
" contours = dict(start=0, \n",
" end=1, \n",
" size=0.1,\n",
" showlines=False),\n",
" line_width = 0))\n",
"\n",
"fig.add_trace(go.Scatter(x=locs_home[:,first_frame + frame_to_plot,0], y=locs_home[:,first_frame + frame_to_plot,1],\n",
" mode='markers',\n",
" showlegend = False,\n",
" marker = dict(color = '#000066',\n",
" size = 10)))\n",
"\n",
"fig.add_trace(go.Scatter(x=locs_away[:,first_frame + frame_to_plot,0], y=locs_away[:,first_frame + frame_to_plot,1],\n",
" mode='markers',\n",
" showlegend = False,\n",
" marker = dict(color = '#b34700',\n",
" size = 10)))\n",
"\n",
"fig.add_trace(go.Scatter(x=locs_ball[[first_frame + frame_to_plot],0], y=locs_ball[[first_frame + frame_to_plot],1],\n",
" mode='markers',\n",
" showlegend = False,\n",
" marker = dict(color = 'black',\n",
" size = 10)))\n",
"\n",
"fig.add_trace(go.Scatter(x=locs_ball[[first_frame + frame_to_plot],0], y=locs_ball[[first_frame + frame_to_plot],1],\n",
" mode='markers',\n",
" showlegend = False,\n",
" marker = dict(color = 'white',\n",
" size = 5)))\n",
"fig.update_layout(title=\"Pitch Control\",\n",
" plot_bgcolor = 'white')\n",
"fig.update_xaxes(showgrid=False, zeroline=False,showticklabels=False)\n",
"fig.update_yaxes(showgrid=False, zeroline=False,showticklabels=False)\n",
"fig.show()"
],
"execution_count": null,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/html": [
"\n",
"\n",
" \n",
" \n",
" \n",
"
\n",
" \n",
"
\n",
"\n",
""
]
},
"metadata": {
"tags": []
}
}
]
}
]
}