AndrewRook / ptplot

Easily make interactive plots of player-tracking data
GNU General Public License v3.0
11 stars 3 forks source link

ptplot

ptplot makes it easy to turn player-tracking data into beautiful, interactive visualizations — including animations! These visualizations can be used to guide data exploration/analysis work, or to embed in webpages to share with the world.

example animation

Installation

ptplot can be installed via pip:

$ pip install ptplot

It is strongly recommended that you install ptplot into a virtual environment, such as with conda:

[After installing conda]
$ conda create -n player_tracking python=3
$ conda activate player_tracking
$ pip install ptplot

You may wish to install some of ptplot's dependencies via conda, specifically pandas and bokeh:

[After installing conda]
$ conda create -n player_tracking python=3 pandas bokeh
$ conda activate player_tracking
$ pip install ptplot

Getting Started

Making your first plot can be as simple as

import pandas as pd

from bokeh.plotting import show

from ptplot import PTPlot
from ptplot.nfl import Field
from ptplot.plot import Positions

data = pd.read_csv("YOUR PLAYER TRACKING DATA")
plot = PTPlot(data) + Field() + Positions("X_COORDINATE_COLUMN", "Y_COORDINATE_COLUMN")
show(plot.draw())

For additional documentation and examples, check out the notebooks in the notebooks/ directory, which can be viewed online with all of the plots correctly rendered via nbviewer:

  1. Basic Plots
  2. Animations
  3. Faceting
  4. Tips and Tricks

Additionally, layers within ptplot have docstrings with more usage details. Those can be accessed either by reading the source code or running help([FUNCTION]) inside of Python.

Development Docs

See here