def plotCorrelation(stats):
#columnsToDrop = ['sleep_interval_max_len', 'sleep_interval_min_len',
# 'sleep_interval_avg_len', 'sleep_inefficiency',
# 'sleep_hours', 'total_hours']
#stats = stats.drop(columnsToDrop, axis=1)
g = sns.PairGrid(stats)
def corrfunc(x, y, **kws):
r, p = scipystats.pearsonr(x, y)
ax = plt.gca()
ax.annotate("r = {:.2f}".format(r),xy=(.1, .9), xycoords=ax.transAxes)
ax.annotate("p = {:.2f}".format(p),xy=(.2, .8), xycoords=ax.transAxes)
if p>0.04:
ax.patch.set_alpha(0.1)
g.map_upper(plt.scatter)
g.map_diag(plt.hist)
g.map_lower(sns.kdeplot, cmap="Blues_d")
g.map_upper(corrfunc)
sns.plt.show()
评论列表
文章目录