import numpy as np
import os
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from scipy import stats
plt.plot(data_fx, data_fx, label='Reference Line', color='red')
sns.regplot(x=data_fx, y=pred_fx, marker='+', label='Distribution Dots', truncate=False, line_kws={'label': 'Regression Line'})
r, p = stats.pearsonr(data_fx, pred_fx)
# info_dict = {'Label': data_fx, 'Prediction': pred_fx}
# info_df = pd.DataFrame(info_dict)
# h = sns.jointplot(x='Label', y='Prediction', data=info_df, kind='hist')
plt.title(f'All data\nPearson correlation coefficient: {r:.2f}')
plt.xlabel('Label')
plt.ylabel('Prediction')
# # sns.histplot(b, color='blue', label='pred')
# # sns.histplot(a, color='yellow', label='label')
plt.legend(loc='best')
plt.show()
需要注意的是,绘制回归曲线有很多种函数可以选择,但大部分是figure level的函数,不方便修改图例
regplot的图例是试出来的,太难画了