Skip to main content

sportypy

Regulation, to-scale sports surfaces for matplotlib: the Python counterpart of sportyR.

Version 1.2.0

Install and try it

pip install sportypy
import matplotlib.pyplot as plt
from sportypy.surfaces.hockey import NHLRink

nhl = NHLRink()
ax = nhl.draw(display_range = "offense")
nhl.scatter([80, 70, 85], [10, -15, 3], ax = ax, color = "#e06000")
plt.show()

The usage guide covers display ranges, units, rotation and colors.

Cookbooks

Real analyses, start to finish: sportsdataverse-py loads the data, sdvplot brings the team colors and logos, and sportypy draws the surface and bins the data onto it. See them all.

Rule-book dimensions

A class per league, drawn to the dimensions in that league's rule book: the NHL, NFL, NBA, MLB, FIFA, the PLL and dozens more.

Plot your data on it

scatter, heatmap, contour, hexbin and arrow on the surface's own coordinates, kept inside its boundaries.

Any units, any view

Draw in the league's units or any other, rotate to a TV or a vertical view, and show the whole surface or just the part you need: an offensive half, a red zone, a house.

Your colors

update_colors() restyles every feature, and update_*_params() redraws a surface for a league sportypy doesn't ship yet.

Parity with sportyR

The same leagues, dimensions and colors as sportyR, checked point for point against what sportyR draws.

Part of the SportsDataverse

Pairs with sdvplot for team logos and colors, and with sdv-py for the play-by-play to put on the surface.