Commit 98354faa authored by Artem Pulkin's avatar Artem Pulkin

presentation: add RMSE text to plot_diagonal

parent dc0b6f3e
Pipeline #43633 passed with stage
in 2 minutes and 32 seconds
......@@ -377,6 +377,9 @@ def plot_diagonal(reference, prediction, ax=None, xlabel="Reference", ylabel="Pr
mx = max(reference.max(), prediction.max())
diag = np.array([mn, mx])
rmse = np.linalg.norm(reference - prediction) / reference.size ** .5
rmse_text = f"RMSE = {rmse:.3e}"
if nmax is not None:
delta = np.abs(reference - prediction)
ind = np.argpartition(delta, -nmax)[-nmax:]
......@@ -388,6 +391,8 @@ def plot_diagonal(reference, prediction, ax=None, xlabel="Reference", ylabel="Pr
ax.plot(reference, prediction, **_kwargs)
ax.plot(diag, diag, color="black", zorder=10)
ax.text(0.05, 0.9, rmse_text, transform=ax.transAxes, ha="left", va="top")
if xlabel:
ax.set_xlabel(xlabel)
if ylabel:
......@@ -403,4 +408,10 @@ def plot_diagonal(reference, prediction, ax=None, xlabel="Reference", ylabel="Pr
ax.relim()
ax.autoscale_view()
text_handles = ax.texts
if len(text_handles) != 1:
raise ValueError(f"Expected one text, found: {len(text_handles):d}")
text_handles[0].set_text(rmse_text)
return ax
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment