Skip to content

Commit

Permalink
update examples and clean doc build
Browse files Browse the repository at this point in the history
  • Loading branch information
theOehrly committed May 8, 2024
1 parent 2912419 commit 13ff4d7
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 40 deletions.
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
warnings.filterwarnings(action='ignore',
message=r'`utils.delta_time` is considered '
r'deprecated.*')
warnings.filterwarnings(action='ignore',
message=r'(COMPOUND_COLORS|DRIVER_COLORS|'
r'DRIVER_TRANSLATE|TEAM_COLORS|TEAM_TRANSLATE|'
r'COLOR_PALETTE) is deprecated and.*')

doc_cache = os.path.abspath('../doc_cache')

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ For some more advanced stuff, it's just a few more steps.
import fastf1
import fastf1.plotting

fastf1.plotting.setup_mpl()
fastf1.plotting.setup_mpl(misc_mpl_mods=False, color_scheme='fastf1')

session = fastf1.get_session(2019, 'Monza', 'Q')

Expand Down
14 changes: 0 additions & 14 deletions docs/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,6 @@ The following module-level attributes are deprecated since version 3.4.0 and
will be removed in a future release.


.. automodule:: fastf1.plotting
:noindex:
:no-members:
:autosummary:
:autosummary-members:
driver_color,
lapnumber_axis,
team_color,
COMPOUND_COLORS,
DRIVER_TRANSLATE,
DRIVER_COLORS,
TEAM_COLORS,
TEAM_TRANSLATE,
COLOR_PALETTE



Expand Down
7 changes: 4 additions & 3 deletions examples/plot_annotate_speed_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import fastf1.plotting


# enable some matplotlib patches for plotting timedelta values and load
# FastF1's default color scheme
fastf1.plotting.setup_mpl(misc_mpl_mods=False)
# Enable Matplotlib patches for plotting timedelta values and load
# FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=True, misc_mpl_mods=False,
color_scheme='fastf1')

# load a session and its telemetry data
session = fastf1.get_session(2021, 'Spanish Grand Prix', 'Q')
Expand Down
7 changes: 5 additions & 2 deletions examples/plot_driver_laptimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
import fastf1.plotting


# The misc_mpl_mods option enables minor grid lines which clutter the plot
fastf1.plotting.setup_mpl(misc_mpl_mods=False)
# Enable Matplotlib patches for plotting timedelta values and load
# FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=True, misc_mpl_mods=False,
color_scheme='fastf1')


###############################################################################
# Load the race session.
Expand Down
6 changes: 5 additions & 1 deletion examples/plot_driver_styling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from fastf1 import plotting


plotting.setup_mpl()
# Enable Matplotlib patches for plotting timedelta values and load
# FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=True, misc_mpl_mods=False,
color_scheme='fastf1')


###############################################################################
Expand Down Expand Up @@ -102,3 +105,4 @@
ax.set_xlabel("Lap Number")
ax.set_ylabel("Lap Time")
plotting.add_sorted_driver_legend(ax, race)
plt.show()
7 changes: 5 additions & 2 deletions examples/plot_laptimes_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import fastf1.plotting


# enabling misc_mpl_mods will turn on minor grid lines that clutters the plot
fastf1.plotting.setup_mpl(mpl_timedelta_support=False, misc_mpl_mods=False)
# Enable Matplotlib patches for plotting timedelta values and load
# FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=True, misc_mpl_mods=False,
color_scheme='fastf1')


###############################################################################
# Load the race session
Expand Down
5 changes: 4 additions & 1 deletion examples/plot_position_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import fastf1.plotting


fastf1.plotting.setup_mpl(misc_mpl_mods=False)
# Load FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=False, misc_mpl_mods=False,
color_scheme='fastf1')


##############################################################################
# Load the session and create the plot
Expand Down
8 changes: 4 additions & 4 deletions examples/plot_qualifying_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from fastf1.core import Laps


# we only want support for timedelta plotting in this example
fastf1.plotting.setup_mpl(mpl_timedelta_support=True,
color_scheme=None,
misc_mpl_mods=False)
# Enable Matplotlib patches for plotting timedelta values
fastf1.plotting.setup_mpl(mpl_timedelta_support=True, misc_mpl_mods=False,
color_scheme=None)


session = fastf1.get_session(2021, 'Spanish Grand Prix', 'Q')
session.load()
Expand Down
7 changes: 4 additions & 3 deletions examples/plot_speed_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import fastf1.plotting


# enable some matplotlib patches for plotting timedelta values and load
# FastF1's default color scheme
fastf1.plotting.setup_mpl(misc_mpl_mods=False)
# Enable Matplotlib patches for plotting timedelta values and load
# FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=True, misc_mpl_mods=False,
color_scheme='fastf1')

# load a session and its telemetry data
session = fastf1.get_session(2021, 'Spanish Grand Prix', 'Q')
Expand Down
6 changes: 4 additions & 2 deletions examples/plot_team_pace_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import fastf1.plotting


# activate the fastf1 color scheme (and no other modifications)
fastf1.plotting.setup_mpl(mpl_timedelta_support=False, misc_mpl_mods=False)
# Load FastF1's dark color scheme
fastf1.plotting.setup_mpl(mpl_timedelta_support=False, misc_mpl_mods=False,
color_scheme='fastf1')


###############################################################################
# Load the race session.
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_who_can_still_win_wdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

##############################################################################
# Get the current driver standings from Ergast.
# Reference https://theoehrly.github.io/Fast-F1-Pre-Release-Documentation/ergast.html#fastf1.ergast.Ergast.get_driver_standings
# Reference https://docs.fastf1.dev/ergast.html#fastf1.ergast.Ergast.get_driver_standings
def get_drivers_standings():
ergast = Ergast()
standings = ergast.get_driver_standings(season=SEASON, round=ROUND)
Expand Down
2 changes: 1 addition & 1 deletion fastf1/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
import matplotlib.pyplot as plt
fastf1.plotting.setup_mpl()
fastf1.plotting.setup_mpl(misc_mpl_mods=False, color_scheme='fastf1')
session = fastf1.get_session(2020, 'Italy', 'R')
session.load()
Expand Down
2 changes: 1 addition & 1 deletion fastf1/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
def __getattr__(name):
if name in ('COMPOUND_COLORS', 'DRIVER_TRANSLATE', 'DRIVER_COLORS',
'TEAM_COLORS', 'TEAM_TRANSLATE', 'COLOR_PALETTE'):
warnings.warn(f"{name} is deprecated and will be removed in a future"
warnings.warn(f"{name} is deprecated and will be removed in a future "
f"version.", FutureWarning)

return globals()[f"_DEPR_{name}"]
Expand Down
8 changes: 4 additions & 4 deletions fastf1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def delta_time(
from fastf1 import utils
from matplotlib import pyplot as plt
plotting.setup_mpl()
plotting.setup_mpl(misc_mpl_mods=False, color_scheme='fastf1')
session = ff1.get_session(2021, 'Emilia Romagna', 'Q')
session.load()
Expand All @@ -62,11 +62,11 @@ def delta_time(
fig, ax = plt.subplots()
# use telemetry returned by .delta_time for best accuracy,
# this ensure the same applied interpolation and resampling
# this ensures the same applied interpolation and resampling
ax.plot(ref_tel['Distance'], ref_tel['Speed'],
color=plotting.team_color(ham['Team']))
color=plotting.get_team_color(ham['Team'], session))
ax.plot(compare_tel['Distance'], compare_tel['Speed'],
color=plotting.team_color(lec['Team']))
color=plotting.get_team_color(lec['Team'], session))
twin = ax.twinx()
twin.plot(ref_tel['Distance'], delta_time, '--', color='white')
Expand Down

0 comments on commit 13ff4d7

Please sign in to comment.