pitch = VerticalPitch(line_color='#cfcfcf', line_zorder=2, pitch_color='#122c3d') fig, ax = pitch.draw(figsize=(4.4, 6.4)) bs = pitch.bin_statistic(df.x, df.y, bins=(12, 8)) heatmap = pitch.heatmap(bs, edgecolors='#122c3d', ax=ax, cmap=pearl_earring_cmap) ############################################################################## # Cyan colormap hexbin fig, ax = pitch.draw() hexmap = pitch.hexbin(df.x, df.y, ax=ax, edgecolors='#122c3d', gridsize=(8, 8), cmap=pearl_earring_cmap) ############################################################################## # Cyan colormap kdeplot pitch = VerticalPitch(line_color='#cfcfcf', line_zorder=2, pitch_color='#15242e') fig, ax = pitch.draw(figsize=(4.4, 6.4)) # note use the colormap with 100 colors for a smoother finish # sphinx_gallery_thumbnail_path = 'gallery/pitch_plots/images/sphx_glr_plot_cmap_007.png' kdeplot = pitch.kdeplot(df.x, df.y, ax=ax, cmap=pearl_earring_cmap_100,
############################################################################## # Create a custom colormap. # Note see the `custom colormaps # <https://mplsoccer.readthedocs.io/en/latest/gallery/pitch_plots/plot_cmap.html>`_ # example for more ideas. flamingo_cmap = LinearSegmentedColormap.from_list("Flamingo - 10 colors", ['#e3aca7', '#c03a1d'], N=10) ############################################################################## # Plot Messi's first game as a false-9. pitch = VerticalPitch(line_color='#000009', line_zorder=2, pitch_color='white') fig, ax = pitch.draw(figsize=(4.4, 6.4)) hexmap = pitch.hexbin(df_false9.x, df_false9.y, ax=ax, edgecolors='#f4f4f4', gridsize=(8, 8), cmap=flamingo_cmap) ############################################################################## # Load a custom font. URL = 'https://github.com/googlefonts/roboto/blob/main/src/hinted/Roboto-Regular.ttf?raw=true' URL2 = 'https://github.com/google/fonts/blob/main/apache/roboto/static/Roboto-Bold.ttf?raw=true' robotto_regular = FontManager(URL) robboto_bold = FontManager(URL2) ############################################################################## # Load images. # Load the StatsBomb logo and Messi picture MESSI_URL = 'https://upload.wikimedia.org/wikipedia/commons/b/b8/Messi_vs_Nigeria_2018.jpg'