Skip to main content
tif1 provides built-in plotting utilities. It also integrates with matplotlib, plotly, and seaborn.

Built-in Plotting

The plotting module provides quick visualization methods for common F1 analysis tasks.

Speed Comparison

Compare the fastest-lap speed traces of two drivers.

Lap Time Evolution

Track how lap times evolve lap by lap, colored by tire compound.

Bar-chart layout guarantees

The native bar charts (plot_race_launch_ratings, plot_downforce_levels, plot_throttle_distance, plot_top_speeds, and plot_qualifying_grid) share layout guarantees. The guarantees keep the chart clean at any grid size, from 5 drivers to the full 22-driver grid.

Tight y-limits at any driver count

Each bar chart tightens its y-limits around the bar rows with tif1.charts._common.set_tight_barh_ylim(ax, n_bars). Horizontal bar rows sit at integer positions 0..n_bars-1, and the helper sets the limits to (-0.5, n_bars - 0.5). Without the helper, matplotlib’s default 5% auto-margins leave empty bands above the first and below the last bar. The proportions also shift as the number of drivers changes. With the helper, the same chart is equally compact for a 15-driver grid and the full 22-driver grid. The bars always fill the axes with the same small padding, and no fixed row count is assumed.

Bar labels always fit inside the canvas

Charts that export with bbox_inches="tight" crop the canvas around their content, so bar labels are never clipped in the saved output. plot_race_launch_ratings is the exception: it exports the full canvas (no bbox_inches crop) to mirror the v2 script. Labels placed past the longest bar would be clipped at the right edge. The chart calls tif1.charts._common.fit_labels_inside_xlim(ax, labels), which iterates the x-limit to a fixed point. The iteration stops when the measured extent of every label sits inside the axes. Labels stay fully visible at any bar width. The value-label bar charts (plot_downforce_levels, plot_throttle_distance, plot_top_speeds) apply the same guarantee for inline display, where no crop happens. finalize_figure accepts a label_fit=(ax, labels) pair and runs fit_labels_inside_xlim after tight_layout. Value labels then stay inside the axes box at any grid size and under any theme’s font sizes. Labels fitted before layout can overflow once large fonts resize the axes.

Reuse the helpers in custom charts

Both helpers are part of tif1.charts._common’s public API, so custom bar charts can opt in to the same guarantees:
For the branded footer, watermark, and footer_y placement used by the race-launch chart, see tif1.charts._common.add_style_branding(fig, style).

Per-driver line chart legends stay beside the plot

The multi-line charts that draw one line per driver (plot_position_changes, plot_track_temperature) anchor their legend outside the axes. The legend sits vertically centred next to the plot and wraps into two columns once the grid exceeds 10 entries. Matplotlib’s default placement drops a 22-entry legend into the middle of the plot and obscures the lines. A top-anchored legend grows downward until it nearly spans the figure. The centred outside anchor keeps the legend balanced and clear of the lines at any grid size. The anchor holds from the 1-driver track-temperature default to the full 22-driver grid.

Matplotlib Integration

For custom visualizations, use matplotlib directly.

Telemetry Overlay

Tire strategy visualization

Plotly for interactive plots

Plotly enables interactive visualizations in Jupyter notebooks.
This section requires the optional plotting library. Install it with pip install plotly.

Interactive speed trace

3D Track Map

Seaborn for statistical plots

Seaborn excels at statistical visualizations.

Lap Time Distribution

Correlation Heatmap

Best Practices

Use Team Colors

Make plots more recognizable by using official team colors.

Handle missing data

Always filter out invalid laps before plotting.

Optimize for Performance

For large datasets, downsample telemetry before plotting.

Export for external tools

Save data for use in other visualization tools.

Plotting API

Plotting reference.

Examples

Visualization examples.

Telemetry Tutorial

Telemetry visualizations.
Last modified on September 3, 2026