
DESCRIPTION
Example- Race Strategies Monaco 2023 (Image 2)
-
The code begins by loading a specific race session, in this case, the 2023 Monaco Grand Prix. This race session contains a wealth of information, including data from each lap driven by the drivers. Once the session is loaded, the laps data is retrieved and stored for further analysis.
-
The primary objective of this project is to examine the strategies employed by drivers during the race. To achieve this, the code focuses on extracting information related to driver stints and compounds. Stints refer to the consecutive laps driven by a driver without pitting, while compounds represent the specific tire types used during those stints.
-
The driver numbers are obtained from the race session, allowing for identification of each driver's stint and compound information. These driver numbers are then converted into three-letter abbreviations using the Fastf1 library, making the data more easily interpretable.
-
The code then processes the stint and compound data, grouping it by driver, stint, and compound. It counts the number of observations within each group, providing the stint length for each driver-compound combination. This information is stored in a dataframe for further analysis and visualization.
-
Next, the code proceeds to plot the strategies employed by each driver during the race. It utilizes Matplotlib, a popular data visualization library, to create a horizontal bar chart. The chart represents each driver's stints as horizontal bars, with the width of each bar indicating the length of the stint. The bars are color-coded based on the compound used, enabling easy identification of the tire strategy for each stint.
-
To enhance the clarity and aesthetics of the plot, the code sets various attributes. The plot is given a title, "2023 Monaco Grand Prix Strategies," providing context to the visualized data. The x-axis is labeled as "Lap Number" to provide a clear understanding of the data being displayed. The y-axis is inverted so that drivers who finish higher in the race appear closer to the top of the plot. Grid lines are turned off to avoid clutter, and unnecessary spines are hidden to maintain a clean and minimalistic appearance.
-
In summary, this project utilizes Fastf1 and Matplotlib to access, process, and visualize Formula 1 telemetry data. It focuses on analyzing and visualizing driver strategies during a specific race session. By leveraging Fastf1's capabilities, the project allows for in-depth exploration of driver stints and compound usage, providing valuable insights into the dynamics and decision-making processes during a Formula 1 race.