Skip to main content
These examples demonstrate how to analyze and visualize lap time data to compare driver and team performance.

Driver Lap Times

Plot a driver’s lap times throughout a race with color coding for tire compounds.

What This Example Shows

  • Filtering laps for a specific driver
  • Using pick_quicklaps() to remove outliers
  • Plotting lap times as a scatter plot
  • Color coding by tire compound
  • Using seaborn for enhanced visualizations

Expected Output

A scatter plot showing lap times progressing through the race, with different colors for SOFT, MEDIUM, and HARD tire compounds. You can see tire degradation as lap times increase within each stint.

Key Functions

  • pick_drivers(): Select laps for specific driver(s)
  • pick_quicklaps(): Filter out slow laps (outliers, yellow flags, pit stops)
  • get_compound_mapping(): Get official tire compound colors

Lap Time Distributions

Visualize lap time distributions for multiple drivers using violin plots.

What This Example Shows

  • Comparing multiple drivers simultaneously
  • Using violin plots to show lap time distributions
  • Overlaying swarm plots to show individual laps
  • Ordering drivers by finishing position
  • Combining driver colors and compound colors

Expected Output

A visualization showing:
  • Violin plots (colored by driver) showing the distribution shape
  • Individual lap points (colored by tire compound) showing actual data
  • Drivers ordered by finishing position (winner on left)
  • Clear comparison of consistency and pace

Understanding the Visualization

Violin Plot Width: Shows the density of lap times at each speed. Wider = more laps at that pace. Swarm Plot Points: Each point is an individual lap, colored by tire compound used. Interpretation:
  • Narrow distributions = consistent driver
  • Lower position = faster pace
  • Point patterns show tire strategy (clusters of colors)

Converting Time Data

When working with libraries that don’t support timedelta objects:

Filtering Laps

FastF1 provides several methods to filter lap data:

Quick Laps Only

By Accuracy

By Track Status

Multiple Filters

Compound Colors

FastF1 automatically maps tire compounds to their official colors:
Compound colors vary by event. The same compound might be labeled as C1, C2, etc., and the colors (SOFT/MEDIUM/HARD) are assigned based on the selected compounds for that race weekend.

Performance Tips

Loading Data Efficiently

Working with Large Datasets