• James Smith

How to create Football Pitches/Goals as Backgrounds in Tableau



Analysing football data provides an excellent opportunity to use visual cues such as football pitch and goal frame outlines to help communicate visual analysis. 2D Football pitches have been popularised across media culture as a method of visualising tactics, pass networks, goals & lineups. These include newspaper & online journalism, video games such as Football Manager and Television broadcasters who are now using increasingly sophisticated tools to recreate passages of play for viewers.


These visualisations work because the creator and audience share the same frame of reference. Football pitches and goal outlines don’t need any further explanation; they are so ingrained in the way viewers consume football that they make a perfect starting point for adding extra layers of analysis.


This blog will focus on how to use both Football Pitch and goal frame outlines in Tableau. In essence, the pitch and goal templates are images that are plotted as a background behind the data. Check out this page for Tableau’s own write up on background images.

Before we start, here’s what you’ll need:


  • Pitch/Goal Template (Download a sample from my website here).

  • Data including X & Y coordinates of match events (eg. StatsBomb/Opta data)

  • Tableau Desktop

  • 5 minutes


The first thing to take note of are the coordinates of your pitch template. This might look something like the example from StatsBomb. This is important as you’ll need to ensure that your X,Y data is in sync with the background image so that events don’t appear to be taking place outside of the pitch area. Also note which way round the coordinates start and finish so that your right back doesn’t mistakenly become a left winger!





Now proceed to Tableau Desktop and load in your data source. In this tutorial we’ll be using a StatsBomb dataset with data about Lionel Messi. Create a new sheet and click on the following:


Map >> Background Images >> [Name of your data source]



This will pop up the window on the left. Click on Add Image… and it’ll pop up the window on the right.





Click the button saying Browse… and search your file system for your football pitch template image. A preview of the pitch should then appear in the window. Next, select the appropriate X & Y fields that will be mapped in front of your pitch template. Finally, enter the boundaries of the left, right, top and bottom of the coordinates (as noted down earlier).


Note: if your pitch template has any white space around the pitch edges, this will need to be factored into your coordinate system. If there is any white space, it may require some tweaking in the Add Background Image window once the image is showing on the background.


My template has a 7 unit border around the edge, so the coordinate system should reflect it as in the above right image.


Hit okay, then bring on your location x & y data into columns and rows respectively. If you double click or drag them into the pane, Tableau will add the fields at an aggregated level (the default being the SUM() of the x and y fields). We need to change both the x and y fields to a dimension so that every single row is showing an individual instance of an event, rather than some kind of aggregation. You can change this by right clicking the pills and selecting dimension. Once you’ve done this you’ll see something that looks like the below with your pitch template in the background (depending on how much data you’ve got).



As there are 132,000 events in this dataset, you can barely make out the pitch underneath as the space is filled by the dots. At this stage you can hover over the points and do some quick spot checks that the locations are mapping to your pitch coordinates. In the above example, I checked that 120,80 was exactly aligned to the bottom right hand corner.


At this level of data, it is impossible to draw any kind of insight. To start to answer your questions you’ll need to start dropping dimensions into the filtering pane. You could start by identifying the positional hotspots for certain players.


In the example below, I’ve added Player name to the filtering system and chosen to only show the touches of Chelsea WFC Centre Back Magdalena Ericsson. To improve the appearance of the visualisation I’ve switched the marks type to ‘density’ and removed the axis headers. We can now visually deduce that Ericsson is a left sided centre back who comes forward for corners.



What about if we wanted to break this out by certain fixtures to analyse her positioning against different types of opposition? By dropping the ‘Fixture’ onto Rows, we can see multiple fixtures at the same time. Focusing on the example below, it becomes clear that against Manchester City, a title rival, Magdalena barely leaves her own half. Meanwhile against Yeovil Town, relegated from the Women’s Premier League at the end of last season, she registers a considerable number of touches in and around the opposition penalty box.



I’m really interested in seeing the use cases that you explore using the pitch templates in Tableau. If you end up making one, share it on Twitter and tag me @sportschord!

©2020 by sportschord