plotting_constants module holds the plotting color data. It contains historically accurate team colors and tyre compound colors for each F1 season from 2018 onwards. The tif1.plotting module reads these mappings when it resolves colors and car image codes. The module contains data only; it defines no functions.
Overview
The module defines four public mappings. All are plain dicts, so a program can read and mutate them directly.YEAR_CONSTANTS
YEAR_CONSTANTS maps each season year to a dict with two keys:
"compound_colors":dict[str, str]mapping compound name to hex color."teams":dict[str, TeamData]mapping a lowercase team key to a team profile.
official and fastf1 are the two colormaps that tif1.plotting.get_team_color and get_driver_color serve.
Compound sets changed over the seasons. The 2018 mapping contains 11 entries: nine track compounds plus UNKNOWN and TEST-UNKNOWN. The 2019 to 2026 mappings contain 7 entries: SOFT, MEDIUM, HARD, INTERMEDIATE, and WET, plus the two unknown markers. The table below shows the 2018 entries:
Some team entries per season (from the actual data):
Each season lists the teams that competed in it. For example, 2023 contains ten team keys, from
alfa romeo to williams; 2025 replaces them with the current grid, including kick sauber and racing bulls.
DEFAULT_COMPOUND_COLORS
DEFAULT_COMPOUND_COLORS is the fallback mapping. tif1.plotting uses it when a session year is unknown or missing from YEAR_CONSTANTS.
TEAM_COLORS
TEAM_COLORS maps a season year to a mapping of timing-data team names to the TracingInsights v2 chart palette. This bright palette is separate from the official and fastf1 colormaps in YEAR_CONSTANTS. The charts module uses it for bar colors.
Example entries for 2025:
The 2026 mapping adds the new teams
Audi (#9a9a9a) and Cadillac (#C5A253).
TEAM_CODES
TEAM_CODES maps a season year to a mapping of timing-data team names to short car image codes. The bundled car artwork in tif1.assets uses these codes. Names with engine suffixes map to the same code. Each team name variant in lap data resolves to the correct artwork.
Example entries for 2024:
How plotting.py consumes the constants
tif1.plotting imports all four mappings and resolves them per session and year:
get_compound_color(compound, session=None)andget_compound_mapping(session=None)read the compound colors for the session year. An unknown year falls back toDEFAULT_COMPOUND_COLORS. An unknown compound resolves to theUNKNOWNcolor.get_team_color(identifier, session, *, colormap="default", exact_match=False)andget_driver_color(...)resolve team profiles built fromYEAR_CONSTANTSfor the session year. They require a session.team_code_mapping(year)returns a copy ofTEAM_CODES[year].team_color_mapping(year)returns a copy ofTEAM_COLORS[year]. The copy has a color for every team name with a car code inTEAM_CODES.get_team_code(identifier, session=None, *, year=None, exact_match=False)resolves a team name to its car image code. It uses the session year when a session is given, and the explicityearotherwise.
Overrides
Two mechanisms change the effective values:- Session-scoped overrides.
tif1.plotting.override_team_constants(identifier, session, *, short_name=None, official_color=None, fastf1_color=None)overrides one team for one session. It requires a session and matches the team exactly. The override applies toget_team_color,get_driver_color, and short-name lookups for that session only. - Direct dict mutation. The mappings are module-level dicts, and the plotting helpers copy them at call time. An in-place change, for example
TEAM_COLORS[2026]["Audi"] = "#ff0000", takes effect on the nextteam_color_mapping(2026)call.
Example
This example runs offline.Related APIs
- Plotting API: the color and style helpers that read these constants
- Assets API: the car artwork selected by
TEAM_CODES - Charts API: the chart functions that consume the palettes
- Core API:
Session, required by the session-scoped color lookups