#!/usr/bin/env python # coding: utf-8 # In[38]: import pandas as pd import matplotlib.pyplot as plt from highlight_text import fig_text import matplotlib as mpl from mplsoccer.pitch import Pitch # In[39]: #Set general use colors text_color = 'w' # In[40]: data = pd.read_csv('shotmaps.csv') # In[41]: data # In[46]: fig, ax = plt.subplots(figsize=(13,8.5)) fig.set_facecolor('#22312b') ax.patch.set_facecolor('#22312b') #The statsbomb pitch from mplsoccer pitch = Pitch(pitch_type='statsbomb', orientation='vertical', pitch_color='#22312b', line_color='#c7d5cc', figsize=(13, 8), constrained_layout=False, tight_layout=True, view='half') pitch.draw(ax=ax) #I invert the axis to make it so I am viewing it how I want plt.gca().invert_yaxis() #plot the points, you can use a for loop to plot the different outcomes if you want plt.scatter(data['x'],data['y'], s=100,c='#ea6969',alpha=.7) s='Barcelona Shot Chart vs Juventus' fig_text(s=s, x=.27,y=.9, fontfamily='Andale Mono', highlight_weights=['bold'], fontsize=24, color=text_color ) total_shots = len(df) fig_text(s=f'Total Shots: {total_shots}', x=.27, y =.67, fontsize=14,fontfamily='Andale Mono',color=text_color) fig_text(s=f'xG: .85', x=.49, y =.67, fontsize=14,fontfamily='Andale Mono',color=text_color) fig_text(s=f'Goals: 0', x=.68, y =.67, fontsize=14,fontfamily='Andale Mono',color=text_color) fig.text(.22,.14,f'@mckayjohns / twitter',fontstyle='italic',fontsize=12,fontfamily='Andale Mono',color=text_color) #plt.savefig('bcnjuveshots.png',dpi=300,bbox_inches = 'tight',facecolor='#22312b') # In[ ]: