with plt.style.context("dark_background"):
plt.rcParams['font.family'] = 'Palatino Linotype' ##set global font
fig, ax = plt.subplots(figsize=(12, 8))
ax.plot(gd_rolling, color=gd_color, linestyle="-.", marker="o", mfc=gd_color, mec="white", markersize=8, mew=0.4, zorder=10) ##goal-difference
ax.plot(xgd_rolling, color=xgd_color, linestyle="-.", marker = "o", mfc=xgd_color, mec="white", markersize=8, mew=0.4, zorder=10) ##expected goals difference
ax.fill_between(x=range(len(gd_rolling)), y1=gd_rolling, y2=xgd_rolling, where = gd_rolling>xgd_rolling,
alpha=0.2, color=gd_color, interpolate=True, zorder=5) ##shade the areas in between
ax.fill_between(x=range(len(gd_rolling)), y1=gd_rolling, y2=xgd_rolling, where = gd_rolling<=xgd_rolling,
alpha=0.2, color=xgd_color, interpolate=True, zorder=5)
ax.grid(linestyle="dashed", lw=0.7, alpha=0.1, zorder=1) ## a faint grid
for spine in ["top", "right"]:
ax.spines[spine].set_visible(False)
ax.set_position([0.08, 0.08, 0.82, 0.78]) ## make space for the title on top of the axes
## labels, titles and subtitles
ax.set(xlabel=f"{window} match rolling mean", xlim=(-1, len(df)-window))
ax.xaxis.label.set(fontsize=12, fontweight='bold')
fig.text(x=0.08, y=0.92, s="Lille | Performance Trend",
ha='left', fontsize=24, fontweight='bold',
path_effects=[pe.Stroke(linewidth=3, foreground='0.15'),
pe.Normal()])
fig_text(x=0.08, y=0.90, ha='left',
fontsize=18, fontweight='bold',
s='Ligue 1 | 2020-21 | <Goal Difference> vs <Expected Goal Difference>',
path_effects=[pe.Stroke(linewidth=3, foreground='0.15'),
pe.Normal()],
highlight_textprops=[{"color": gd_color},
{"color": xgd_color}])
fig.savefig("xg-trend-line-chart", dpi=180) ##save image