コード例 #1
0
_ = axes[3].axis('off')

##############################################################################
# Vertical shot map with kdeplot marginals
# ----------------------------------------
# The jointgrid is flexible. You can filter the marginal axes with
# ax_left, ax_top, ax_left, ax_right. Here we set the bottom and right
# marginal axes to display for a single team.

fig, axes, _, _ = vertical_pitch.jointgrid(
    figheight=10,
    left=None,
    bottom=0.15,
    grid_height=0.7,
    marginal=0.1,
    # plot without endnote/ title axes
    endnote_height=0,
    title_height=0,
    # here we filter out the left and top marginal axes
    ax_top=False,
    ax_bottom=True,
    ax_left=False,
    ax_right=True)
# typical shot map where the scatter points vary by the expected goals value
# using alpha for transparency as there are a lot of shots stacked around the six-yard box
sc_team2 = vertical_pitch.scatter(df_team2.x,
                                  df_team2.y,
                                  s=df_team2.shot_statsbomb_xg * 700,
                                  alpha=0.5,
                                  ec='black',
                                  color='#697cd4',
                                  ax=axes[0])
コード例 #2
0
txt1 = axs['pitch'].text(x=15, y=70, s=team1, fontproperties=fm.prop, color=red,
                         ha='center', va='center', fontsize=30)
txt2 = axs['pitch'].text(x=105, y=70, s=team2, fontproperties=fm.prop, color=blue,
                         ha='center', va='center', fontsize=30)

##############################################################################
# Vertical shot map with kdeplot marginals
# ----------------------------------------
# The jointgrid is flexible. You can filter the marginal axes with
# ax_left, ax_top, ax_left, ax_right. Here we set the bottom and right
# marginal axes to display for a single team.

fig, axs = vertical_pitch.jointgrid(figheight=10, left=None, bottom=0.15,
                                    grid_height=0.7, marginal=0.1,
                                    # plot without endnote/ title axes
                                    endnote_height=0, title_height=0,
                                    axis=False,  # turn off title/ endnote/ marginal axes
                                    # here we filter out the left and top marginal axes
                                    ax_top=False, ax_bottom=True,
                                    ax_left=False, ax_right=True)
# typical shot map where the scatter points vary by the expected goals value
# using alpha for transparency as there are a lot of shots stacked around the six-yard box
sc_team2 = vertical_pitch.scatter(df_team2.x, df_team2.y, s=df_team2.shot_statsbomb_xg * 700,
                                  alpha=0.5, ec='black', color='#697cd4', ax=axs['pitch'])
# kdeplots on the marginals
# remember to flip the coordinates y=x, x=y for the marginals when using vertical orientation
team2_hist_x = sns.kdeplot(y=df_team2.x, ax=axs['right'], color='#697cd4', shade=True)
team2_hist_y = sns.kdeplot(x=df_team2.y, ax=axs['bottom'], color='#697cd4', shade=True)
txt1 = axs['pitch'].text(x=40, y=80, s=team2, fontproperties=fm_rubik.prop, color=pitch.line_color,
                         ha='center', va='center', fontsize=60)

##############################################################################