API: plotting
apply_style(color_scheme='fastf1', timedelta_support=True)
Apply a consistent Matplotlib style.
Uses FastF1's built-in styling (dark theme by default) and a few readability tweaks.
Source code in src/fastf1_analytics/plotting.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
fmt_laptime_seconds(sec)
Format seconds as M:SS.sss (e.g., 73.456 -> '1:13.456').
Source code in src/fastf1_analytics/plotting.py
103 104 105 106 | |
get_compound_color(compound)
Return hex color for a tyre compound (FastF1 or fallback).
Source code in src/fastf1_analytics/plotting.py
125 126 127 128 129 130 131 132 133 134 135 136 137 | |
get_driver_color(driver, *, session=None)
Return the (team) color for a driver abbreviation in a given session.
Source code in src/fastf1_analytics/plotting.py
98 99 100 | |
get_team_color(team, *, session=None)
Return a hex color for a team. Tries FastF1's mapping; falls back to a local mapping so charts work even without a session object or for alternate team names.
Source code in src/fastf1_analytics/plotting.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
lighten_color(color, amount=0.25)
Return a lightened variant of a hex color (used as a 'secondary' line color).
amount=0 keeps the same color; amount=1 goes to white.
Source code in src/fastf1_analytics/plotting.py
140 141 142 143 144 145 146 147 148 149 | |
savefig(fig, path, *, dpi=220)
Save figure to path with consistent DPI and tight layout; ensure parent dir exists.
Source code in src/fastf1_analytics/plotting.py
152 153 154 155 156 157 158 159 160 161 | |
seconds_formatter()
Matplotlib formatter that renders seconds as M:SS.sss.
Source code in src/fastf1_analytics/plotting.py
109 110 111 | |
Examples
from fastf1_analytics.plotting import get_team_color, get_compound_color, savefig, apply_style
apply_style()
print(get_team_color("Ferrari"))
print(get_compound_color("Soft"))