Skip to main content

Package to allow creation of football pitch charts using plotly

Project description

plotly-football-pitch

tests

This repo contains code to plot football pitches using plotly. Currently only horizontal pitches are supported, with the origin located at the bottom left corner of the pitch.

Examples

Further examples can be found in examples/pitch.ipynb.

from plotly_football_pitch import make_pitch_figure, PitchDimensions


dimensions = PitchDimensions()
fig = make_pitch_figure(dimensions)
fig.show()

basic pitch

from plotly_football_pitch import (
    make_pitch_figure,
    PitchDimensions,
    SingleColourBackground
)


dimensions = PitchDimensions()
fig = make_pitch_figure(
    dimensions,
    pitch_background=SingleColourBackground("#81B622"),
)
fig.show()

green pitch

import numpy as np

from plotly_football_pitch import make_pitch_figure, PitchDimensions


dimensions = PitchDimensions()
fig = make_pitch_figure(dimensions)

# define number of grid squares for heatmap data
width_grid = 12
length_grid = 15

data = np.array([
    [random.random() for _ in range(length_grid)]
    for _ in range(width_grid)
])

fig = add_heatmap(fig, data)
fig.show()

basic pitch with heatmp

Installation

pip install plotly_football_pitch

Development installation

make setup-env
source .venv/bin/activate
make dev-install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plotly_football_pitch-0.0.2.tar.gz (8.9 kB view hashes)

Uploaded Source

Built Distribution

plotly_football_pitch-0.0.2-py3-none-any.whl (9.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page