【发布时间】:2021-05-19 15:53:54
【问题描述】:
我正在尝试使用r2、p 和rmse 值使用seaborn.regplot 制作散点图。但是下面的代码返回错误AttributeError: 'AxesSubplot' object has no attribute 'map_dataframe'
fig, axes = plt.subplots(1, 2, figsize=(15, 5), sharey=True)
g = sns.regplot(x='est_fmc', y='1h_surface', data=new_df, ax=axes[0])
def annotate(data, **kws):
slope, intercept, rvalue, pvalue, stderr = scipy.stats.linregress(x = data['est_fmc'], y= data['1h_surface'] )
rmse = mean_squared_error(data['est_fmc'], data['1h_surface'], squared=False)
print(slope, intercept, rvalue, pvalue, rmse)
ax = plt.gca()
ax.text(.02, .9, 'r2={:.2f}, p={:.2g}, rmse = {:.2f}'.format(rvalue**2, pvalue, rmse),
transform=ax.transAxes)
g.map_dataframe(annotate)
g = sns.regplot(x='est_fmc', y='1h_profile', data=new_df, ax = axes[1] )
def annotate(data, **kws):
slope, intercept, rvalue, pvalue, stderr = scipy.stats.linregress(x = data['est_fmc'], y= data['1h_profile'] )
rmse = mean_squared_error(data['est_fmc'], data['1h_profile'], squared=False)
print(slope, intercept, rvalue, pvalue, rmse)
ax = plt.gca()
ax.text(.02, .9, 'r2={:.2f}, p={:.2g}, rmse = {:.2f}'.format(rvalue**2, pvalue, rmse),
transform=ax.transAxes)
g.map_dataframe(annotate)
有办法解决吗?非常感谢任何帮助。
【问题讨论】: