.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/pitch_plots/plot_sb360_frame.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_pitch_plots_plot_sb360_frame.py: ============= StatsBomb 360 ============= This example shows how to plot the StatsBomb 360 data. Code by `@abhisheksh_98 `_ .. GENERATED FROM PYTHON SOURCE LINES 8-35 .. image-sg:: /gallery/pitch_plots/images/sphx_glr_plot_sb360_frame_001.png :alt: plot sb360 frame :srcset: /gallery/pitch_plots/images/sphx_glr_plot_sb360_frame_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt from mplsoccer import Pitch, Sbopen import numpy as np ## load in Statsbomb360 data remotely parser = Sbopen() frames, visible = parser.frame(3788741) ## get plotting data frame_idx = 50 frame_id = visible.iloc[50].id visible_area = np.array(visible.iloc[frame_idx].visible_area).reshape(-1, 2) player_position_data = frames[frames.id == frame_id] teammate_locs = player_position_data[player_position_data.teammate] opponent_locs = player_position_data[~player_position_data.teammate] ## set up pitch p = Pitch(pitch_type='statsbomb') fig, ax = p.draw(figsize=(12,8)) p.scatter(teammate_locs.x, teammate_locs.y, c='orange', s=80, ec='k', ax=ax) p.scatter(opponent_locs.x, opponent_locs.y, c='dodgerblue', s=80, ec='k', ax=ax) p.polygon([visible_area], color=(1, 0, 0, 0.3), ax=ax) plt.show() ##to see the plot. You don't need this if you're using a jupyter notebook .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.284 seconds) .. _sphx_glr_download_gallery_pitch_plots_plot_sb360_frame.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sb360_frame.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sb360_frame.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_sb360_frame.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_