assets module ships chart artwork inside the package. The artwork covers car images per team per season (2018 to 2026), tyre compound images, and brand fonts. Plots render this artwork fully offline, without a network fetch at plot time. The tif1.assets directory tree holds the files; this module provides path helpers, cached loaders, and matplotlib annotation helpers.
Overview
The bundled layout is:tif1/assets/cars/{year}/{CODE}.png— one car image per team code per season.tif1/assets/tyres/{COMPOUND}.png— tyre images forSOFT,MEDIUM,HARD,HARD1,INTERMEDIATE,WET, andNone(the generic fallback).tif1/assets/fonts/—Azonix.otf,coolvetica rg.otf,GreatVibes-Regular.ttf,Tenada.ttf.
ASSET_DIR, CARS_DIR, TYRES_DIR, and FONTS_DIR as pathlib.Path objects.
The chart function plot_race_launch_ratings uses this module: it draws car images with add_car_images, tyre images with add_tyre_image_at_position, and headings with font_path. The shared chart style code in tif1.charts._common also resolves its logo and heading fonts through font_path.
Discovery
available_car_years
available_team_codes
AMR, APN, FER, HAA, KS, MCL, MER, RB, RBR, and WIL. Raises FileNotFoundError when no images are bundled for the year.
list_fonts
Path helpers
All path helpers return apathlib.Path and raise FileNotFoundError when the asset is not bundled. The error message lists the available assets for the year.
car_image_path
car_image_path(2024, "RBR").
tyre_image_path
tyre_image_path("SOFT").
font_path
font_path("Azonix.otf"). Pass the result to matplotlib.font_manager.FontProperties(fname=...).
Cached loaders
load_car_image
functools.cache. Repeated calls for the same year and code return the same array without disk reads.
load_tyre_image
Matplotlib helpers
The helpers draw bundled artwork on an axes withmatplotlib.offsetbox.AnnotationBbox and OffsetImage. Rows whose artwork is not bundled are skipped without an error.
add_car_images
df. The image for each row is drawn at (df[x_col], row_index + y_offset). The vertical position is the row index in the DataFrame, not the value of y_col. This matches the bar-chart layout the helper was written for.
matplotlib.axes.Axes
required
Axes to annotate.
DataFrame
required
DataFrame with one row per car to draw.
int
required
Season year that selects the car artwork.
str
default:"\"LapTimeDelta\""
Column with the x-position of each car.
str
default:"\"Driver\""
Column with the row label. The drawn y-position is the row index.
str
default:"\"Team_code\""
Column with the team code, for example
"RBR".float
default:"0.5"
Zoom factor of the car image.
int
default:"-110"
Horizontal offset of the image from the point, in points.
float | None
default:"None"
When set, rows where
df[x_col] <= threshold are skipped.float
default:"0.0"
Vertical offset applied to the y position.
add_tyre_images
df. An unknown compound falls back to the generic None artwork. As with add_car_images, the drawn y-position is the row index plus y_offset.
add_car_image_at_position
(x, y) on the axes. When no image is bundled for the year and code, the call returns without drawing.
add_tyre_image_at_position
(x, y) on the axes. An unknown compound falls back to the generic None artwork.
Example
This example runs offline with the Agg matplotlib backend.tif1.plotting.get_team_code or tif1.plotting.team_code_mapping. The codes come from the TEAM_CODES mapping in tif1.plotting_constants.
Related APIs
- Charts API:
plot_race_launch_ratingsand the other chart functions - Plotting API:
get_team_codeandteam_code_mappingfor name-to-code resolution - Plotting Constants API: the
TEAM_CODESmapping behind the car image codes - Jupyter API: notebook plot setup