Esempio n. 1
0
fm = FontManager()  # a mplsoccer fontmanager with the default Robotto font
opta_pitch.scatter(x,
                   y,
                   s=250,
                   marker='x',
                   alpha=0.8,
                   edgecolor='black',
                   facecolor='#6778d0',
                   ax=ax_opta)
TEXT = ('The initial points are inside\n'
        'the penalty area, six yard box,\n'
        'and on the penalty-spot')
_ = ax_text(50,
            70,
            TEXT,
            va='center',
            ha='center',
            fontproperties=fm.prop,
            fontsize=20,
            ax=ax_opta)

# draw the scaled event points
custom_pitch.scatter(x_naive,
                     y_naive,
                     marker='p',
                     alpha=0.9,
                     facecolor='#9750a1',
                     zorder=2.5,
                     edgecolor='black',
                     s=250,
                     ax=ax_custom)
custom_pitch.scatter(x_relative,
Esempio n. 2
0
        # plot the title for each player axis
        # here we use f-strings to combine the variables from the dataframe and text
        # we plot the title at x=0, y=-5
        # this is the left hand-side of the pitch (x=0) and between
        # top of the y-axis (y=0) and the top of the padding (y=-10, remember pad_top = 10)
        # note that the StatsBomb y-axis is inverted, so you may need
        # to change this if you use another pitch_type (e.g. 'uefa').
        # We also use the highlight-text package to highlight complete_pass green
        # so put <> around the number of completed passes.
        total_pass = len(complete_pass) + len(incomplete_pass)
        annotation_string = (f'{lineup_player.position_abbreviation} | '
                             f'{lineup_player.short_name} | '
                             f'<{len(complete_pass)}>/{total_pass} | '
                             f'{round(100 * len(complete_pass)/total_pass, 1)}%')
        ax_text(0, -5, annotation_string, ha='left', va='center', fontsize=20,
                fontproperties=fm_scada.prop,  # using the fontmanager for the google font
                highlight_textprops=[{"color": '#56ae6c'}], ax=ax)

        # add information for subsitutions on/off and arrows
        if not np.isnan(lineup_team.iloc[idx].off):
            ax.text(116, -10, str(lineup_team.iloc[idx].off.astype(int)), fontsize=20,
                    fontproperties=fm_scada.prop,
                    ha='center', va='center')
            ax.annotate('', (120, -2), (112, -2), arrowprops=red_arrow)
        if not np.isnan(lineup_team.iloc[idx].on):
            ax.text(104, -10, str(lineup_team.iloc[idx].on.astype(int)), fontsize=20,
                    fontproperties=fm_scada.prop,
                    ha='center', va='center')
            ax.annotate('', (108, -2), (100, -2), arrowprops=green_arrow)

# plot on the last Pass Map
Esempio n. 3
0
                                fontsize=28,
                                color='#000009',
                                fontproperties=robotto_regular.prop,
                                ha='center',
                                va='center')
highlight_text = [{
    'color': '#800610',
    'fontproperties': robboto_bold.prop
}, {
    'color': '#08306b',
    'fontproperties': robboto_bold.prop
}]
ax_text(0.5,
        0.3,
        TITLE_STR2,
        ha='center',
        va='center',
        fontsize=18,
        color='#000009',
        fontproperties=robotto_regular.prop,
        highlight_textprops=highlight_text,
        ax=axs['title'])

# sphinx_gallery_thumbnail_path = 'gallery/pitch_plots/images/sphx_glr_plot_hexbin_003.png'

# Messi Photo from: https://en.wikipedia.org/wiki/Lionel_Messi#/media/File:Messi_vs_Nigeria_2018.jpg
# License: https://creativecommons.org/licenses/by-sa/3.0/;
# Creator: Кирилл Венедиктов

plt.show()  # If you are using a Jupyter notebook you do not need this line