figure = earthkit.plots.Figure(size=(8, 6))
subplot = figure.add_subplot()
for year in range(1940, 2023):
data = get_year_data(df, year)
if year == 2022:
subplot.line(y=data, x=dates, linewidth=0.5, color="#e6e6e6", label="1940-2022")
else:
subplot.line(y=data, x=dates, linewidth=0.5, color="#e6e6e6")
subplot.line(y=data_reference, x=dates, color="grey", linestyle="--", label="1991-2020 mean")
subplot.line(y=get_year_data(df, 2023), x=dates, color="orange", label="2023")
subplot.line(y=get_year_data(df, 2024), x=dates[:len(get_year_data(df, 2024))], color=C3S_RED, label="2024")
subplot.ax.xaxis.set_ticklabels([])
subplot.set_minor_xticks("M1", format="%b")
subplot.ax.set_ylabel("temperature (°C)")
subplot.ax.legend(ncol=4, loc=(0.15, 1.05), frameon=False)
figure.fig.suptitle(
"Global surface air temperature\n"
"Daily average • Data ERA5 • Credit: C3S/ECMWF"
)
figure.show()