Setup Matplotlib
Before creating visualizations, configure matplotlib for optimal F1 data plotting:Setup Options
mpl_timedelta_support: Enables proper formatting of lap times and time deltas on plot axes. Essential for plottingLapTime, sector times, and other timedelta values.color_scheme: Set to'fastf1'for the signature dark theme with optimized colors, orNonefor default matplotlib styling.
Team Colors
FastF1 automatically provides official F1 team colors for any session:Using Team Colors in Plots
Driver Styling
Apply consistent driver-specific colors and line styles to plots:Sorted Driver Legends
Automatically sort legend entries by team and driver order:Custom Driver Styles
Define custom styling variants while keeping official team colors:'auto' is replaced with the official team color automatically.
Tire Compound Colors
Visualize tire strategies with official compound colors:Tire Strategy Visualization
Telemetry Visualization
Speed Traces
Gear Visualization on Track Map
Available Plotting Functions
FastF1’s plotting module provides these key functions:| Function | Description |
|---|---|
setup_mpl() | Configure matplotlib for FastF1 |
get_team_color() | Get official team color |
get_team_name() | Get official team name |
list_team_names() | List all teams in session |
get_driver_color() | Get driver’s team color |
get_driver_style() | Get driver plot styling |
get_driver_name() | Get driver’s full name |
get_driver_abbreviation() | Get driver abbreviation |
list_driver_names() | List all drivers in session |
add_sorted_driver_legend() | Add sorted legend to plot |
get_compound_color() | Get tire compound color |
get_compound_mapping() | Get compound-to-color mapping |
list_compounds() | List available compounds |
Best Practices
- Always call
setup_mpl()before creating plots - Enable timedelta support when plotting lap times:
setup_mpl(mpl_timedelta_support=True) - Pass the session object to color/style functions for accurate season data
- Use
pick_quicklaps()to filter outlier lap times before visualization - Invert Y-axis for time-based plots so faster times appear at the top
- Use official colors via
get_team_color()andget_driver_style()for professional appearance
Next Steps
- Learn about data analysis techniques for extracting insights
- Explore performance optimization for faster plotting
- See the API Reference for complete plotting documentation
