import matplotlib.pyplot as plt
import numpy as np

# Match order (Latest to Earliest)
matches = ["Final/\nBronze", "SF", "QF", "R16", "R32", "GS3", "GS2", "GS1"]
x = np.arange(len(matches))

data = {
    "Spain":{
        "xGF":[2.29,1.63,1.96,1.69,2.32,0.86,2.30,2.10],
        "xGA":[0.22,0.31,0.34,0.63,0.32,0.20,0.14,0.20],
        "Opp":["ARG","FRA","BEL","POR","AUT","URU","KSA","CPV"]
    },

    "Argentina":{
        "xGF":[0.22,1.59,1.94,2.84,2.26,2.13,2.36,1.26],
        "xGA":[2.29,0.53,0.47,0.89,0.47,0.76,0.53,0.32],
        "Opp":["ESP","ENG","SUI","EGY","CPV","JOR","AUT","ALG"]
    },

    "England":{
        "xGF":[2.88,0.53,1.04,1.61,2.16,1.56,1.36,3.20],
        "xGA":[2.88,1.59,0.68,1.88,0.77,0.66,0.17,0.70],
        "Opp":["FRA","ARG","NOR","MEX","COD","PAN","GHA","CRO"]
    },

    "France":{
        "xGF":[2.88,0.31,3.69,1.45,3.24,1.50,2.67,1.79],
        "xGA":[2.88,1.63,0.14,0.13,0.70,1.70,0.63,0.53],
        "Opp":["ENG","ESP","MAR","PAR","SWE","NOR","IRQ","SEN"]
    }
}

fig, axes = plt.subplots(2,2,figsize=(15,10),sharex=True,sharey=True)
axes = axes.flatten()

for ax, (team, values) in zip(axes, data.items()):

    diff = np.array(values["xGF"]) - np.array(values["xGA"])

    ax.plot(
        x,
        diff,
        color="darkgreen",
        marker="o",
        linewidth=3,
        markersize=8
    )

    ax.fill_between(
        x,
        0,
        diff,
        where=(diff >= 0),
        color="forestgreen",
        alpha=0.25
    )

    ax.fill_between(
        x,
        0,
        diff,
        where=(diff < 0),
        color="crimson",
        alpha=0.25
    )

    ax.axhline(0, color="black", linewidth=1)

    # Labels
    for xi, d, opp in zip(x, diff, values["Opp"]):

        offset = 12 if d >= 0 else -18

        ax.annotate(
            f"{d:+.2f}",
            (xi, d),
            xytext=(0, offset),
            textcoords="offset points",
            ha="center",
            fontsize=8,
            fontweight="bold",
            bbox=dict(facecolor="white",
                      edgecolor="none",
                      alpha=0.8)
        )

        ax.annotate(
            opp,
            (xi, d),
            xytext=(0, -offset),
            textcoords="offset points",
            ha="center",
            fontsize=8,
            fontweight="bold",
            color="navy"
        )

    ax.set_title(team, fontsize=15, fontweight="bold")
    ax.set_xticks(x)
    ax.set_xticklabels(matches)
    ax.grid(True, linestyle="--", alpha=0.35)
    ax.set_ylim(-2.5,3.5)

fig.suptitle(
    "2026 FIFA World Cup Semi-finalists\nMatch-by-Match xG Difference (xGF − xGA)",
    fontsize=19,
    fontweight="bold"
)

fig.supxlabel("Tournament Stage", fontsize=13, fontweight="bold")
fig.supylabel("xG Difference", fontsize=13, fontweight="bold")

plt.tight_layout(rect=[0,0,1,0.95])
plt.show()

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: