# 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
pitch1._draw_rectangle(ax1, pitch1.dim.left, pitch1.dim.bottom,
                       rect1_length, rect1_width, color='#b94e45', alpha=0.5)
pitch1._draw_rectangle(ax1, pitch1.dim.left, pitch1.dim.penalty_area_top,
                       rect1_length, rect1_width, color='#b94e45', alpha=0.5)

# top middle
rect2_width = (pitch2.dim.width - pitch2.dim.penalty_area_width) / 2
rect2_length = pitch2.dim.length / 2
Example #2
0
                 df_shot_event.y,
                 ax=axs['pitch'],
                 alpha=0.2,
                 zorder=1.1,
                 color='#cb5a4c',
                 goal='right')

# fontmanager for google font (robotto)
robotto_regular = FontManager()

# plot the jersey numbers
for i, label in enumerate(df_freeze_frame.player_jersey_number):
    pitch.annotate(label, (df_freeze_frame.x[i], df_freeze_frame.y[i]),
                   va='center',
                   ha='center',
                   color='white',
                   fontproperties=robotto_regular.prop,
                   fontsize=15,
                   ax=axs['pitch'])

# add a legend and title
legend = axs['pitch'].legend(loc='center left', labelspacing=1.5)
for text in legend.get_texts():
    text.set_fontproperties(robotto_regular.prop)
    text.set_fontsize(20)
    text.set_va('center')

# title
axs['title'].text(0.5,
                  0.5,
                  f'{df_shot_event.player_name.iloc[0]}\n{team1} vs. {team2}',