-
Notifications
You must be signed in to change notification settings - Fork 6
/
over_under_perform.py
60 lines (54 loc) · 1.47 KB
/
over_under_perform.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# =============================================================================
# File: over_under_perform.py
# Author: Andre Brener
# Created: 22 Aug 2017
# Last Modified:
# Description: description
# =============================================================================
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
df = pd.read_csv('rodrigo_mora_xg.csv', index_col=0)
date = df.index.values.tolist()
amount_data = len(date)
x = np.linspace(1, 100, len(date))
rg_list = df['goals_90'].tolist()
xg_list = df['xg_90'].tolist()
rg = np.array(rg_list)
xg = np.array(xg_list)
fig, ax = plt.subplots(figsize=(12, 6))
plt.plot(x, xg, color='k', lw=2)
plt.title('Evolución de Goles vs xG: Rodrigo Mora', fontsize=16, weight='bold')
ax.fill_between(
x,
xg,
rg,
where=rg >= xg,
facecolor='lime',
alpha=0.3,
interpolate=True,
label='Rendimiento supera Goles Esperados')
ax.fill_between(
x,
xg,
rg,
where=rg < xg,
facecolor='r',
alpha=0.3,
interpolate=True,
label='Rendimiento por debajo de Goles Esperados')
ax.annotate(
'Línea Negra: xG por 90 Minutos',
xy=(15, 1),
size=10,
ha="center",
color='0.3')
plt.ylim((0, 1.1))
plt.xticks(x, date, rotation='vertical')
plt.tick_params(axis='both', which='major', labelsize=13)
plt.legend(fontsize='x-large')
ax.set_axis_bgcolor('whitesmoke')
plt.grid('off')
plt.tight_layout()
plt.show()