How to Create a Soccer Football Pitch in Python | mplsoccer [Download PDF + Ipynp]

How to Create a Soccer Football Pitch in Python | mplsoccer [Download PDF + Ipynp]

Installation (
mplsoccer)

To install the latest version via pip

⌘ pip install mplsoccer

To upgrade to the latest version from a previous version via pip

⌘ pip install -U mplsoccer

You may also need to upgrade mplsoccer dependencies such as seaborn.


1. Grass pitches

Grass pitches in Python | mplsoccer


from mplsoccer import Pitch
import matplotlib.pyplot as plt
pitch = Pitch(pitch_color=’grass’, line_color=’white’, stripe=True)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(10, 5))
plt.show()


2. Choose your favorite colors

Black & White Football Pitch mplsoccer


pitch = Pitch()
pitch = Pitch(pitch_color=’Black’, line_color=’white’)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(10, 5))


3. e.g. useful if you want to plot pitch lines over heatmaps

e.g. useful if you want to plot pitch lines over heatmaps | mplsoccer


# e.g. useful if you want to plot pitch lines over heatmaps
pitch = Pitch(line_zorder=2)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(10, 5))


4. example plotting an Opta/ Stats Perform pitch

EXAMPLE PLOTTING AN OPTA/ STATS PERFORM PITCH | mplsoccer


# example plotting an Opta/ Stats Perform pitch
pitch = Pitch(pitch_type=’opta’)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(10, 5))


5. Example plotting a tracab pitch

example plotting a tracab pitch | mplsoccer


# example plotting a tracab pitch
pitch = Pitch(pitch_type=’tracab’,
pitch_length=102, pitch_width=68,
axis=True, label=True) # showing axis labels is optional
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(10, 5))


6. Axis

AXIS | mplsoccer


pitch = Pitch(axis=True, label=True, tick=True)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(10, 5))


7. Juego de Posición

Juego de Posición | mplsoccer


#Juego de Posición
pitch = Pitch(positional=True, shade_middle=True, positional_color=’#eadddd’, shade_color=’#f2f2f2′)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(10, 5))


8. Vertical full

Vertical full | mplsoccer


#Vertical full
pitch = VerticalPitch(half=False)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(12, 8))


9. Horizontal half

Horizontal half | mplsoccer


#Horizontal half
pitch = Pitch(half=True)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(12, 8))


10. Vertical half

Vertical half | mplsoccer
– Vertical half | mplsoccer


#Vertical half
pitch = VerticalPitch(half=True)
# specifying figure size (width, height)
fig, ax = pitch.draw(figsize=(12, 8))

Downloadable files:

Download the high-res PDF 👇
Here

Download Ipynp File 👇
Here

Published by

One thought on “How to Create a Soccer Football Pitch in Python | mplsoccer [Download PDF + Ipynp]

Leave a Reply

Your email address will not be published. Required fields are marked *