示例#1
0
                             va='center',
                             str_format='{:.0%}',
                             path_effects=path_eff)

##############################################################################
# Plot the chart again with a title
# ---------------------------------
# We will use mplsoccer's grid function to plot a pitch with a title and endnote axes.
pitch = VerticalPitch(pitch_type='statsbomb',
                      line_zorder=2,
                      pitch_color='#1e4259')
fig, axs = pitch.grid(
    endnote_height=0.03,
    endnote_space=0,
    title_height=0.08,
    title_space=0,
    # Turn off the endnote/title axis. I usually do this after
    # I am happy with the chart layout and text placement
    axis=False,
    grid_height=0.84)
fig.set_facecolor('#1e4259')

# heatmap and labels
bin_statistic = pitch.bin_statistic_positional(df.x,
                                               df.y,
                                               statistic='count',
                                               positional='full',
                                               normalize=True)
pitch.heatmap_positional(bin_statistic,
                         ax=axs['pitch'],
                         cmap=pearl_earring_cmap,
示例#2
0
            all_cmap_dict[key] = cmap

##############################################################################
# Cmasher kdeplot
# ---------------
# Here's all the cmasher colormaps plotted as a grid so you can find your
# favorite.
pitch = VerticalPitch(line_color='#cfcfcf',
                      line_zorder=2,
                      pitch_color='#122c3d')
fig, axs = pitch.grid(
    nrows=11,
    ncols=4,
    space=0.1,
    figheight=40,
    title_height=0,
    endnote_height=0,  # no title/ endnote
    grid_width=0.9,
    grid_height=0.98,
    bottom=0.01,
    left=0.05)
cmap_names = list(all_cmap_dict.keys())
for idx, ax in enumerate(axs['pitch'].flat):
    cmap_name = f'cmr.{cmap_names[idx]}'
    cmap = all_cmap_dict[cmap_names[idx]]
    kdeplot = pitch.kdeplot(df.x,
                            df.y,
                            ax=ax,
                            cmap=cmap,
                            shade=True,
                            levels=100)