Esempio n. 1
0
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',
                   va='center',
                   ha='center',
                   size=16,
                   weight='bold',
                   ax=ax)
title = ax.set_title("{} {} Formation vs {}".format(TEAM, FORMATION, OPPONENT),
                     size=28,
                     y=0.97,
                     color='#c7d5cc')
fig.set_facecolor("#22312b")
Esempio n. 2
0
pitch = Pitch(pitch_type='statsbomb', pitch_color='grass', stripe=True)
fig, ax = pitch.draw(figsize=(16, 11))

# plotting
ax.set_title('The first Game Messi played in the false 9 role',
             fontsize=30,
             pad=20)

# plot the kernel density estimation
pitch.kdeplot(df_false9.x, df_false9.y, ax=ax, cmap='plasma', linewidths=3)

# annotate
pitch.annotate('6-2 thrashing \nof Real Madrid', (25, 10),
               color='white',
               fontsize=25,
               ha='center',
               va='center',
               ax=ax)
pitch.annotate('more events', (70, 30), (20, 30),
               ax=ax,
               color='white',
               ha='center',
               va='center',
               fontsize=20,
               arrowprops=dict(facecolor='white', edgecolor='None'))
pitch.annotate('fewer events', (51, 20), (20, 20),
               ax=ax,
               color='white',
               ha='center',
               va='center',
               fontsize=20,
                       **hatch_kwargs)
pitch5._draw_rectangle(ax5, pitch5.dim.left, pitch5.dim.penalty_area_bottom,
                       pitch5.dim.penalty_area_length, pitch5.dim.penalty_area_width,
                       **hatch_kwargs)
pitch5._draw_rectangle(ax5, pitch5.dim.penalty_area_right, pitch5.dim.penalty_area_bottom,
                       pitch5.dim.penalty_area_length, pitch5.dim.penalty_area_width,
                       **hatch_kwargs)

# fixed box text

# top
penalty_area_coordinates2 = [pitch2.dim.penalty_area_length / 2,
                             pitch2.dim.length - pitch2.dim.penalty_area_length / 2]
for coordinate in penalty_area_coordinates2:
    pitch2.annotate('Fixed\nsize', (coordinate, pitch2.dim.center_width),
                    rotation=90, color='#6f706f',
                    bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 5, 'edgecolor': 'None'},
                    ax=ax2, **font_kwargs)

# bottom
penalty_area_coordinates5 = [pitch5.dim.penalty_area_length / 2,
                             pitch5.dim.length - pitch5.dim.penalty_area_length / 2]
for coordinate in penalty_area_coordinates5:
    pitch5.annotate('Fixed\nsize', (coordinate, pitch5.dim.center_width), color='#6f706f',
                    bbox={'facecolor': 'white', 'alpha': 0.5, 'pad': 5, 'edgecolor': 'None'},
                    ax=ax5, **font_kwargs)

# shaded areas

# top left
rect1_width = (pitch1.dim.width - pitch1.dim.penalty_area_width) / 2
rect1_length = pitch1.dim.length