예제 #1
0
##############################################################################
# Plotting

pitch = Pitch(
    pitch_type='statsbomb',
    pitch_color='#22312b',
    line_color='#c7d5cc',
)
fig, ax = pitch.draw(figsize=(16, 11),
                     constrained_layout=True,
                     tight_layout=False)
pass_lines = pitch.lines(passes_between.x,
                         passes_between.y,
                         passes_between.x_end,
                         passes_between.y_end,
                         lw=passes_between.width,
                         color=color,
                         zorder=1,
                         ax=ax)
pass_nodes = pitch.scatter(average_locs_and_count.x,
                           average_locs_and_count.y,
                           s=average_locs_and_count.marker_size,
                           color='red',
                           edgecolors='black',
                           linewidth=1,
                           alpha=1,
                           ax=ax)
for index, row in average_locs_and_count.iterrows():
    pitch.annotate(row.name,
                   xy=(row.x, row.y),
                   c='white',
예제 #2
0
##############################################################################
# View the pass dataframe.

df_pass.head()

##############################################################################
# Plotting

# Setup the pitch
pitch = Pitch(pitch_type='statsbomb', pitch_color='#22312b', line_color='#c7d5cc')
fig, ax = pitch.draw(figsize=(16, 11), constrained_layout=False, tight_layout=True)

# Plot the completed passes
lc1 = pitch.lines(df_pass[mask_complete].x, df_pass[mask_complete].y,
                  df_pass[mask_complete].end_x, df_pass[mask_complete].end_y,
                  lw=5, transparent=True, comet=True, label='completed passes',
                  color='#ad993c', ax=ax)

# Plot the other passes
lc2 = pitch.lines(df_pass[~mask_complete].x, df_pass[~mask_complete].y,
                  df_pass[~mask_complete].end_x, df_pass[~mask_complete].end_y,
                  lw=5, transparent=True, comet=True, label='other passes',
                  color='#ba4f45', ax=ax)

# Plot the legend
ax.legend(facecolor='#22312b', edgecolor='None', fontsize=20, loc='upper left', handlelength=4)

# Set the title
ax.set_title(f'{team1} passes vs {team2}', fontsize=30)

# Set the figure facecolor
예제 #3
0
# Setup the pitch
pitch = Pitch(pitch_type='statsbomb',
              pitch_color='#22312b',
              line_color='#c7d5cc')
fig, ax = pitch.draw(figsize=(16, 11),
                     constrained_layout=False,
                     tight_layout=True)
fig.set_facecolor('#22312b')

# Plot the completed passes
lc1 = pitch.lines(df_pass[mask_complete].x,
                  df_pass[mask_complete].y,
                  df_pass[mask_complete].end_x,
                  df_pass[mask_complete].end_y,
                  lw=5,
                  transparent=True,
                  comet=True,
                  label='completed passes',
                  color='#ad993c',
                  ax=ax)

# Plot the other passes
lc2 = pitch.lines(df_pass[~mask_complete].x,
                  df_pass[~mask_complete].y,
                  df_pass[~mask_complete].end_x,
                  df_pass[~mask_complete].end_y,
                  lw=5,
                  transparent=True,
                  comet=True,
                  label='other passes',
                  color='#ba4f45',
예제 #4
0
              linewidth=LINEWIDTH,
              line_alpha=1,
              goal_alpha=1,
              goal_type='box')
fig, ax = pitch.grid(grid_height=0.9,
                     title_height=0.06,
                     axis=False,
                     endnote_height=0.04,
                     title_space=0,
                     endnote_space=0)
fig.set_facecolor(BACKGROUND_COLOR)
pitch.lines(
    df_pass.x,
    df_pass.y,
    df_pass.end_x,
    df_pass.end_y,
    capstyle='butt',  # cut-off the line at the end-location.
    linewidth=LINEWIDTH,
    color=PASS_COLOR,
    comet=True,
    ax=ax['pitch'])

# plotting the titles and endnote
text_effects = [
    path_effects.Stroke(linewidth=3, foreground='black'),
    path_effects.Normal()
]
ax['title'].text(0.5,
                 0.3,
                 f'{team1} passes versus {team2}',
                 path_effects=text_effects,
                 va='center',