Skip to main content

Beautiful, battle-tested football UI components for Python.

Project description

Campos

Beautiful, battle-tested football UI components for Python.

Campos gives you production-quality football visualisations with minimal code. Pass in your data, get back a matplotlib figure. No styling code required.

from campos import shot_map, use_theme
from campos.schema import Shot

use_theme("dark")

shots = [
    Shot(id="1", xg=0.72, x=0.9, y=0.5, outcome="goal", body_part="foot"),
    Shot(id="2", xg=0.11, x=0.75, y=0.3, outcome="saved", body_part="head"),
    Shot(id="3", xg=0.45, x=0.88, y=0.6, outcome="goal", body_part="foot"),
]

fig = shot_map(shots, title="Salah vs Arsenal")
fig.savefig("shots.png", dpi=150, bbox_inches="tight")

Install

pip install campos-football

Requires Python 3.10+.

Components

Component What it does Example
shot_map Half-pitch shot plot with xG sizing, body-part shapes, outcome colours shot_map(shots, title="xG Map")
radar_chart Polar radar with comparison polygon and reversed-scale support radar_chart(categories, comparison_label="League avg")
player_table Sortable table with colour-scaled metric cells player_table(players, metrics, sort_by="Goals")
percentile_ribbon Horizontal percentile bars with comparison overlay percentile_ribbon(rows, comparison_label="Median")
percentile_group Category header + aggregate score + nested ribbon percentile_group("Shooting", rows, aggregate_score=88)
category_score_card Small tile with score, comparison delta, progress arc category_score_card("Creation", 91, comparison_score=72)
ranked_list Leaderboard with rank, name, and value bars ranked_list(items, title="Top Scorers")
player_hero Player card with name, position pill, and meta line player_hero(player, club=club)

All components accept canonical schema types (Player, Shot, PercentileRow, RadarCategory) and return a matplotlib Figure.

Compose

Combine multiple components into a single figure:

from campos import compose, player_hero, percentile_ribbon, shot_map

fig = compose(
    [player_hero(player), percentile_ribbon(stats), shot_map(shots)],
    layout="vertical",
    title="Scouting Report",
)

Layouts: "vertical", "horizontal", "grid".

Themes

from campos import use_theme

use_theme("dark")   # dark background, light text (default)
use_theme("light")  # light background, dark text

Club accent override:

import matplotlib as mpl
mpl.rcParams["campos.accent.primary"] = "#C8102E"  # Liverpool red

Data schema

All coordinates normalised to 0-1 on both axes. Provider-native formats (StatsBomb 120x80, Opta 100x100) should be normalised before passing to Campos.

Type Required fields Key optional fields
Player id, name position, nation, age, club_id
Club id, name colour_primary, crest_url
Shot id, xg x, y, outcome, body_part
PercentileRow stat_id, label, value, percentile category, comparison_percentile
RadarCategory label, value, max comparison_value, reversed

Quality bar

Every component passes a 12-axis quality checklist before shipping. See Testing for details.

Status

v0.1.0rc1 - Release candidate. All 8 components pass the 12-axis quality bar with 272 tests. Looking for beta testers.

Licence

MIT

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

campos_football-0.1.0rc2.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

campos_football-0.1.0rc2-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file campos_football-0.1.0rc2.tar.gz.

File metadata

  • Download URL: campos_football-0.1.0rc2.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for campos_football-0.1.0rc2.tar.gz
Algorithm Hash digest
SHA256 ec165f6a7b1e72aab63432d1b4c26ec0eddddd537153b3d027505d6509406a45
MD5 4b0c97b69f91f03c39d2b9d79ffa2564
BLAKE2b-256 a8d442649313fb4a7cde99029b9059385c4ec7024d16b59a4c3f5ebeaacfe19a

See more details on using hashes here.

Provenance

The following attestation bundles were made for campos_football-0.1.0rc2.tar.gz:

Publisher: publish.yml on withqwerty/campos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file campos_football-0.1.0rc2-py3-none-any.whl.

File metadata

File hashes

Hashes for campos_football-0.1.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 4d085431ef90cca68bd32f1611b4d03f1c9d5ef15ca2c410dc364071bea82baa
MD5 a249ac2c23f9f44a637ff2089ff26d1f
BLAKE2b-256 dbc23ceab4d75f6d11c7e4b4f54be6908fd9e450b2f49088e7b1faf54149baa2

See more details on using hashes here.

Provenance

The following attestation bundles were made for campos_football-0.1.0rc2-py3-none-any.whl:

Publisher: publish.yml on withqwerty/campos

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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