Skip to content
Jupyter Notebook to produce static and animated win probability charts from nflscrapR data.
Jupyter Notebook Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fonts
output
.gitignore
README.md
__init__.py
team_colors.py
team_names.py
wp-charts.ipynb

README.md

nfl-wp-charts

A Jupyter Notebook to produce static and animated win probability charts from nflscrapR data.

Examples:

Static chart without smoothing

Static

Static chart with smoothing

Static

Animated chart with smoothing

Animated Excuse the potato quality of the gif. The code outputs .mp4 files with better definition.

Requirements

The notebook is written using Python 3.7 and relies on (at least) the below packages. I strongly recommend installing Python via Anaconda, which will also include these packages out-of-the-box:

  • jupyter
  • pandas
  • numpy
  • scipy
  • matplotlib
  • seaborn

In addition, these packages need to be installed individually:

  • csaps (to smooth the sometimes overly jumpy WP curves)
  • requests (to fetch and join week numbers to the nflscrapR data)
  • celluloid (easy matplotlib animation)
  • ffmpeg (to output animations to video files)

You also need to feed the code with some nflscrapR data, of course.

Usage notes

The notebook is named wp-charts.ipynb. Simply open it using Jupyter, tweak the parameters as you like and execute the code!

Note that an animated chart using the suggested 500 frames will take about 5 minutes to render.

Fonts

The visualizations are optimized to use Nunito Sans for titles and team scores, as well as IBM Plex Mono for labels and ticks. Both fonts have open licences and are included in the /fonts folder. If you don't want to use these fonts, make sure to adjust the font sizes and spacing, as it might look unbalanced.

Feedback

Feel free to leave an issue in the repo or reach out to me on Twitter.

You can’t perform that action at this time.