Skip to content

Latest commit

 

History

History

04. Introduction To Tracking Data

Introduction To Tracking Data

Content:

Steps to create a football pitch map:

  • Here we will be discussing the step one can perform to make a plot of football pitch.

  • This code was developed by Laurie Shaw.

  • We here are actually discussing the function plot_pitch present in utility_functions_viz.py, i.e. the steps perfomed in the given funtion to plot the pitch map.

  • In the function we are actually converting all the dimensions of pitch from yards to meters.(since field dimensions are typically defined in yards). We have used 105x68 meters^2 pitch area for our plot.

  • Note: We will take the origin of the quadrant as the centre of our pitch that we will plot.

  • So here are the steps:

    • Code Line 25: We have defined a plot of size (12,8).

    • Code Line 28-30: We have defined some of the parameters that we will use while plotting such as the color for our plot and linewidth.

    • Code Line 33-37: We have defined the field dimensions in meters. Pitch length and pitch width has been halved because we are using origin as the center for our pitch.

    • Code Line 40-50: Since the football dimensions are typically defined in yards so we have converted them into meters.

    • Code Line 53: Setting the background color, your plot now looks like this: Capture

    • Code Line 56-57: Plotting the half-way line of the pitch and the center circle of the pitch. The plot will look like: Capture

    • Code Line 60-61: Here defining points for x and y to plot or circle. Let's see how this works, the circle whose center is at origin is basically derived by the formula: x^2 + y^2 = r^2 and at Line 60 we have our y coordinates and we have radius too with us so by using the given formula as x = sqrt(r^2 - y^2) we will find our x coordinates.

    • Code Line 64-65: Plotting our center circle, Line 64 will plot the right hand side of the circle and Line 65 will plot the left hand side of the circle. Here is our plot(note that the plot just has been magnified only to show the circle because everything in our plot is still empty): Capture

    • Code Line 68: First selecting s = -1 to show how the plotting works inside the for loop.

    • Code Line 70-71: Plotting the pitch boundary for left and bottom of the pitch. The plot now looks like this: Capture

    • Code Line 74: Plotting the goal post by using goal_line_width. The plot now looks like this: Capture

    • Code Line 77-79: Plotting the six yard box line by line. First, plot after Line 77, second after Line 77 and third after Line 77. Plots:

      Capture Capture Capture

    • Code Line 82-84: Plotting the penalty box line by line. First, plot after Line 82, second after Line 83 and third after Line 84. Plots:

      Capture Capture Capture

    • Code Line 87: Plotting the penalty spot. Here's how the plot looks like: Capture

    • Code Line 90-91: Here defining the x and y points for our corner flag quadrant. y has been defined from 0 to 1 because we just need one circular quadrant.

    • Code Line 92: Plotting the first corner flag quadrant. Plot will now looks like this: Capture

    • Code Line 93: Plotting our second flag quadrant. Plot will now looks like this: Capture

    • Code Line 96-97: Defining the x and y points for our D, here the D_length is the length of the chord that defines the D.

    • Code Line 98: Plotting the D: Capture

    • Now the loop will run on more time for sign = 1 and will plot the right hand side of the pitch. Plot: Capture

    • Code Line 101-104: Removing all x ticks and y ticks as well as there labels. The plot will now look like: Capture

    • Code 107-111: Setting the axis limits for the plots. x coordinate will be from (-55.5, 55.5) and y coordinate will be from (-37, 37), the value 3 has been added to have a border around the pitch. So our final plot looks like: Capture

Analysis:

  • Note: In our pitch map, home team is attacking from left to right and away team is attacking from right to left.

  • Firstly we have drawn out the shot map for both the teams, from the plot we can see every kind of shots, i.e. shots which were on traget, blocked shots, shots which were saved, long range shots and of course the goals. The home team's two goals were from the edge of the six yard box having a good xG value and one of the shot that led to a goal was a long range shot with a low xG value. For away team the two goals were from inside the penalty box, they were trying many long range shots that end up either blocked or saved or of target. Here is the plot for shot-map: shot_map

  • Then we have plotted some of the event maps for the first three goals:

    • This is the event map for the first goal of the match scored by the home team.

    • We have numbered the events in the order.

    • Events from 1 to 8 were all pass event and the 9th event was a shot that led to the first goal.

    • Note: Ball carry data is not present in the data set that is why the events sometime looks incomplete,

    • e.g. event from end point 3 to 4 starting point should be a carry event since it's not in the data set that why it's looking empty. event_map_goal_1

    • Next is the event map for the second goal of the match event_map_goal_2

    • And at last for the third goal of the match. event_map_goal_3

  • Next we have plotted our tracking data:

    • Here at first we have plotted the position of all 22 players on the pitch at the start of the kick off: kick_off

    • Then we have plotted the tracking data when home team scored their first goal: home_team_first_goal

    • Tracking plot when away team scored their first goal: away_team_first_goal

    • Tracking plot when home team scored the last goal of the match last_goal

  • And then we went on and took Player 9 for our analysis/plotting and plotted his shots on goal and tracking data when he scored the goal. player_9_shots position_player9_goal