def _corrfunc(x, y, **kws):
""" Annotate grid with correaltion coefficient.
Solution from http://stackoverflow.com/a/30942817
"""
if args.c == 'spearman':
r, _ = stats.spearmanr(x, y)
corr_type = 'Rho'
elif args.c == 'pearson':
r, _ = stats.pearsonr(x, y)
corr_type = 'r'
else:
raise Exception('Invalid correlation statistic.')
correlations.append(r)
ax = plotter.plt.gca()
ax.annotate("{} = {:.2f}".format(corr_type, r),
xy=(.1, .9), xycoords=ax.transAxes)
评论列表
文章目录