import matplotlib.pyplot as plt from pathlib import Path from os import makedirs import numpy as np def plot_diagonal(outpath, xs, predictions:list): makedirs(Path(outpath).parent, exist_ok=True) # Create scatter plot plt.figure(figsize=(10, 10)) plt.xlim(0, 1) plt.ylim(0, 1) plt.plot([0, 1], [0, 1], color='black', linestyle='--') for method_name, ys in predictions: pear_cor = np.corrcoef(xs, ys)[0, 1] plt.scatter(xs, ys, label=f'{method_name} {pear_cor:.2f}') plt.legend() # Add labels and title plt.xlabel('True Accuracy') plt.ylabel('Estimated Accuracy') # Display the plot # plt.show() plt.savefig(outpath)