add_sorted_driver_legend#
- fastf1.plotting.add_sorted_driver_legend(ax, session, *args, **kwargs)[source]#
Adds a legend to the axis where drivers are grouped by team and within each team they are shown in the same order that is used for selecting plot styles.
This function is a drop-in replacement for calling Matplotlib’s
ax.legend()method. It can only be used when driver names or driver abbreviations are used as labels for the legend.This function supports the same
*argsand**kwargsas Matplotlib’sax.legend(), including thehandlesandlabelsarguments. Check the Matplotlib documentation for more information.There is no particular need to use this function except to make the legend more visually pleasing.
- Parameters:
ax (
Axes) – An instance of a MatplotlibAxesobjectsession (
Session) – the session for which the data should be obtained*args – Matplotlib legend args
**kwargs –
Matplotlib legend kwargs
- Returns:
matplotlib.legend.Legend
Examples using
fastf1.plotting.add_sorted_driver_legend#