{"id":1054,"date":"2021-04-25T21:47:02","date_gmt":"2021-04-25T21:47:02","guid":{"rendered":"https:\/\/miguelpdl.com\/weblog\/?p=1054"},"modified":"2021-04-25T21:47:02","modified_gmt":"2021-04-25T21:47:02","slug":"good-practice-in-football-visualisation","status":"publish","type":"post","link":"https:\/\/miguelpdl.com\/weblog\/good-practice-in-football-visualisation\/","title":{"rendered":"Good Practice in Football Visualisation"},"content":{"rendered":"\n<p>This is a review of a special guest lecture from Opta&#8217;s Peter McKeever were he gives some insights in to how to make better data visualisations.<\/p>\n\n\n\n<p>In this video Peter covers:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Elements of Matplotlib<\/li><li>Under the Hood: rcParams<\/li><li>Layering objects with zorder in plots<\/li><li>Works through a real world example<\/li><\/ul>\n\n\n\n<p>The origin of the code is available on <a href=\"https:\/\/github.com\/petermckeeverPerform\/friends-of-tracking-viz-lecture\">Github under the project &#8220;friends-of-tracking-viz-lecture&#8221;<\/a> and worked through in this video.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/md0pdsWtq_o?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-GB&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span>\n<\/div><\/figure>\n\n\n\n<p>Peter&#8217;s slides are available <a href=\"https:\/\/github.com\/petermckeeverPerform\/friends-of-tracking-viz-lecture\/blob\/master\/docs\/pmk-beyond-the-default-mpl.pdf\">here in this PDF document<\/a>. Peter also has an excellent <a href=\"http:\/\/petermckeever.com\/2020\/10\/how-to-draw-a-football-pitch\/\">blog with code and further examples<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Set up<\/h2>\n\n\n\n<p>Under the organisation on <a href=\"https:\/\/github.com\/mmoffoot\">Github called mmoffoot<\/a> I forked the <a href=\"https:\/\/github.com\/mmoffoot\/friends-of-tracking-viz-lecture\">&#8220;friends-of-tracking-viz-lecture&#8221; repo into the mmoffoot<\/a> area.<\/p>\n\n\n\n<p>Then I created a new branch called <a href=\"https:\/\/github.com\/mmoffoot\/friends-of-tracking-viz-lecture\/tree\/tottenham\">&#8216;tottenham&#8217;<\/a> in this area to cover the changes I made.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What was coded<\/h2>\n\n\n\n<p>This is another Jupyter Notebook, but this time I just could not get it to load up the highlight_text python library and so I had to create a <a href=\"https:\/\/github.com\/mmoffoot\/friends-of-tracking-viz-lecture\/blob\/tottenham\/notebooks\/lecture-notebook.py\">bog standard Python programme<\/a> to run through this code base.<\/p>\n\n\n\n<p>Then I found that highlight_text has changed its interface slightly since Peter coded against it. For example in the Notebook there&#8217;s the line<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>htext.fig_htext(s.format(team,ssn_start,ssn_end),0.15,0.99,highlight_colors=&#91;primary], highlight_weights=&#91;\"bold\"],string_weight=\"bold\",fontsize=22, fontfamily=title_font,color=text_color)<\/code><\/pre>\n\n\n\n<p>I had to change it to<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>htext.fig_text(0.15,0.86,s.format(team,ssn_start,ssn_end),highlight_colors=&#91;primary], highlight_weights=&#91;\"bold\"],fontweight=\"bold\",fontsize=22, fontfamily=title_font,color=text_color)<\/code><\/pre>\n\n\n\n<p>Given that Peter McKeever has run through all the elements coded via the YouTube video and there&#8217;s an associated slide deck this is a really nice resource to get started on exact visual items and how to then code them up. Of course for devilment I&#8217;ve gone for a Tottenham theme for the final output.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"800\" data-attachment-id=\"1055\" data-permalink=\"https:\/\/miguelpdl.com\/weblog\/good-practice-in-football-visualisation\/goaldiff_tottenham\/\" data-orig-file=\"https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?fit=800%2C800&amp;ssl=1\" data-orig-size=\"800,800\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"goaldiff_Tottenham\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?fit=300%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?fit=800%2C800&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?resize=800%2C800&#038;ssl=1\" alt=\"\" class=\"wp-image-1055\" srcset=\"https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?resize=300%2C300&amp;ssl=1 300w, https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?resize=150%2C150&amp;ssl=1 150w, https:\/\/i0.wp.com\/miguelpdl.com\/weblog\/wp-content\/uploads\/2021\/04\/goaldiff_Tottenham.png?resize=768%2C768&amp;ssl=1 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><figcaption>Tottenham&#8217;s goal difference from 2010\/2011 to 2019\/2020<\/figcaption><\/figure>\n\n\n\n<p>Peter also talks about the <a href=\"https:\/\/lisacharlotterost.de\/\">blog posts by Lisa Rost<\/a> which are well worth a review on how to visualise data. He also gives a pointer towards <a href=\"https:\/\/twitter.com\/timbayer93?lang=en\">Tim Bayer<\/a> and his work doing some things for <a href=\"https:\/\/timbayer93.github.io\/fpl-player-valuations\/\">Fantasy premier league<\/a>, all of which is excellent.<\/p>\n\n\n\n<p>Finally there&#8217;s <a href=\"https:\/\/pypi.org\/project\/themepy\/\">ThemePy<\/a> which is being developed, it is a theme selector \/ creator and aesthetic manager for Matplotlib. This wrappers aim is to simplify the process of customising matplotlib plots and to enable users who are relatively new to python or matplotlib to move beyond the default plotting params we are given with matplotlib.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a review of a special guest lecture from Opta&#8217;s Peter McKeever were he gives some insights in to how to make better data visualisations. In this video Peter covers: Elements of Matplotlib Under the Hood: rcParams Layering objects with zorder in plots Works through a real world example The origin of the code [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,199],"tags":[185,216],"class_list":["post-1054","post","type-post","status-publish","format-standard","hentry","category-football","category-mathematical-modelling-of-football","tag-football","tag-visualisations"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7O9Cj-h0","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts\/1054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/comments?post=1054"}],"version-history":[{"count":1,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts\/1054\/revisions"}],"predecessor-version":[{"id":1056,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/posts\/1054\/revisions\/1056"}],"wp:attachment":[{"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/media?parent=1054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/categories?post=1054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/miguelpdl.com\/weblog\/wp-json\/wp\/v2\/tags?post=1054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}