A Jupyter Notebook to produce static and animated win probability charts from nflscrapR data.
Static chart without smoothing
Static chart with smoothing
Animated chart with smoothing
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:
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.
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.
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.
Feel free to leave an issue in the repo or reach out to me on Twitter.