Single
from scipy import stats
result_0928 = stats.pearsonr(df_0928["dt_1"], y=df_0928["prev_deltaMs"])
print("coef: {0}".format(result_0928.statistic))
print("p-value: {0}".format(result_0928.pvalue))
import matplotlib.pyplot as plt
plt.scatter(df_0928["dt_1"],
df_0928["prev_deltaMs"],
c ="blue",
label="pearson coef:{0} p-value:{1}".format(round(result_0928.statistic, 3), round(result_0928.pvalue,8)))
plt.xlabel("dt_1")
plt.ylabel("prev_deltaMs")
plt.title("09/28. pearson coef:{0} p-value:{1}".format(
round(result_0928.statistic, 3),
round(result_0928.pvalue, 7)))
# plt.legend()
plt.show()
Subplots
fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(12, 4))
ax[0].scatter(df_0928["dt_1"], df_0928["prev_deltaMs"])
ax[0].title.set_text("09/28. pearson coef:{0} p-value:{1}".format(
round(result_0928.statistic, 3),
round(result_0928.pvalue, 15)))
ax[0].set(xlabel='dt_1', ylabel='prev_deltaMs')
ax[1].scatter(df_0928["dt_1"], df_0928["prev_deltaMs"])
ax[1].title.set_text("09/28. pearson coef:{0} p-value:{1}".format(
round(result_0928.statistic, 3),
round(result_0928.pvalue,15)))
ax[1].set(xlabel='dt_1', ylabel='prev_deltaMs')
fig.subplots_adjust(wspace=.4)
plt.show()