{ "cells": [ { "cell_type": "code", "execution_count": 183, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from mplsoccer.pitch import Pitch\n", "from scipy.spatial import Voronoi, voronoi_plot_2d\n", "import highlight_text" ] }, { "cell_type": "code", "execution_count": 172, "metadata": {}, "outputs": [], "source": [ "import matplotlib.font_manager\n", "from IPython.core.display import HTML\n", "\n", "def make_html(fontname):\n", " return \"
{font}: {font}
\".format(font=fontname)\n", "\n", "code = \"\\n\".join([make_html(font) for font in sorted(set([f.name for f in matplotlib.font_manager.fontManager.ttflist]))])" ] }, { "cell_type": "code", "execution_count": 178, "metadata": {}, "outputs": [], "source": [ "barca_x=[93,96,99,102,104,95,86,79,89]\n", "barca_y=[9,22,33,44,56,63,52,33,22]\n", "barca = list(np.zeros((9,),dtype=int))\n", "\n", "opp_x=[99,100,102,104,104,102,97,98,94,77]\n", "opp_y=[14,22,33,43,46,55,37,27,21,45]\n", "opp = list(np.ones((10,),dtype=int))\n", "\n", "df = pd.DataFrame({\n", " 'x':barca_x+opp_x,\n", " 'y':barca_y+opp_y,\n", " 'team':barca+opp\n", "})" ] }, { "cell_type": "code", "execution_count": 179, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\n", " | x | \n", "y | \n", "team | \n", "
---|---|---|---|
0 | \n", "93 | \n", "9 | \n", "0 | \n", "
1 | \n", "96 | \n", "22 | \n", "0 | \n", "
2 | \n", "99 | \n", "33 | \n", "0 | \n", "
3 | \n", "102 | \n", "44 | \n", "0 | \n", "
4 | \n", "104 | \n", "56 | \n", "0 | \n", "
5 | \n", "95 | \n", "63 | \n", "0 | \n", "
6 | \n", "86 | \n", "52 | \n", "0 | \n", "
7 | \n", "79 | \n", "33 | \n", "0 | \n", "
8 | \n", "89 | \n", "22 | \n", "0 | \n", "
9 | \n", "99 | \n", "14 | \n", "1 | \n", "
10 | \n", "100 | \n", "22 | \n", "1 | \n", "
11 | \n", "102 | \n", "33 | \n", "1 | \n", "
12 | \n", "104 | \n", "43 | \n", "1 | \n", "
13 | \n", "104 | \n", "46 | \n", "1 | \n", "
14 | \n", "102 | \n", "55 | \n", "1 | \n", "
15 | \n", "97 | \n", "37 | \n", "1 | \n", "
16 | \n", "98 | \n", "27 | \n", "1 | \n", "
17 | \n", "94 | \n", "21 | \n", "1 | \n", "
18 | \n", "77 | \n", "45 | \n", "1 | \n", "