Visualize which gear is used at each point on the circuit
Gear usage across a lap shows corner characteristics, acceleration zones, and the technical demands of a circuit. This tutorial creates a color-coded track map. Each segment is colored by the gear in use.
Convert telemetry to numpy arrays and create line segments for plotting.
# Extract X and Y coordinatesx = np.array(tel['X'].values)y = np.array(tel['Y'].values)# Create line segments from consecutive pointspoints = np.array([x, y]).T.reshape(-1, 1, 2)segments = np.concatenate([points[:-1], points[1:]], axis=1)# Get gear data as float arraygear = tel['nGear'].to_numpy().astype(float)
Low-speed corners: Gears 1-3 indicate tight corners requiring heavy braking
Medium-speed corners: Gears 4-5 show flowing sections where momentum is maintained
High-speed sections: Gears 6-8 reveal straights and fast corners
Shift points: Transitions between colors show where drivers change gears
Different circuits have distinct gear usage profiles. Street circuits like Monaco use lower gears extensively, while high-speed tracks like Monza spend more time in top gears.
The native chart accepts the shared filters plus a few chart-specific options. Change the gear color scale with cmap, or write the figure straight to a file with save_path:
import tif1# Custom colormap, saved directly to a filefig, ax = tif1.plot_gear_shifts( 2021, 'Austrian Grand Prix', 'Q', cmap='tab20', save_path='gear_shifts_on_track.png', dpi=150,)plt.show()
The colorbar is scaled from the data, not the fixed 8-gear range in the example above. The chart works for any gearbox.
The whole workflow above is wrapped in a single native function:
import tif1import matplotlib.pyplot as plt# One call: loads the session and colors the track by gearfig, ax = tif1.plot_gear_shifts(2021, 'Austrian Grand Prix', 'Q')plt.show()# Or save straight to a file# tif1.plot_gear_shifts(2021, 'Austrian Grand Prix', 'Q', save_path='gear_shifts_on_track.png')