Code Monkey home page Code Monkey logo

mplsoccer's Introduction

mplsoccer

mplsoccer is a Python library for drawing soccer/football pitches in Matplotlib and loading StatsBomb open-data.

Installation

Use the package manager pip to install mplsoccer.

pip install mplsoccer

Docs

Here are the docs for mplsoccer.

Quick start

Plot a StatsBomb pitch

from mplsoccer.pitch import Pitch
pitch = Pitch(pitch_color='grass', line_color='white', stripe=True)
fig, ax = pitch.draw()

alt text

Why mplsoccer exists

mplsoccer shares some of the tools I built for the OptaPro Analytics Forum. At the time there weren’t any open-sourced python tools. Now alternatives exist, such as matplotsoccer.

By using mplsoccer, I hope that you can spend more time building insightful graphics rather than having to learn to draw pitches from scratch.

Advantages of mplsoccer

mplsoccer:

  1. draws 7 different pitch types by changing a single argument, which is useful as there isn’t a standardised data format
  2. extends matplotlib to plot heatmaps, (comet) lines, footballs and rotated markers
  3. flips the data coordinates when in a vertical orientation so you don’t need to remember to flip them
  4. creates tidy dataframes for StatsBomb data, which is useful as most of the alternatives produce nested dataframes

License

MIT

Contributions

Contributions are welcome. It would be great to add the following functionality to mplsoccer:

  • pass maps
  • pass sonars
  • Voronoi diagrams

Examples to help others are also welcome for a gallery.

Please get in touch at [email protected] or @numberstorm on Twitter.

Inspiration

mplsoccer was inspired by other people's work:

  • Peter McKeever inspired the API design
  • ggsoccer - a library for plotting pitches in R
  • lastrow - often tweets animations from matches and the accompanying code
  • fcrstats - tutorials for using football data
  • fcpython - Python tutorials for using football data
  • Karun Singh - tweets some interesting football analytics and visuals
  • StatsBomb - great visual design and free open-data
  • John Burn-Murdoch's tweet got me interested in football analytics

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.