kde plot
kdeplot 知乎; kdeplot和distplot; 绘制核密度曲线图
seaborn学习笔记(五):绘制多子图 ; Python中取余、除法、取整的操作逻辑; Seaborn:如何在分布图中添加垂直线 (sns.distplot)
结果的分析:核密度图解释
![](https://img2022.cnblogs.com/blog/2355125/202210/2355125-20221030194402740-1298701242.png)
columns = [r'\alpha', r'\beta', 'm', r'\theta_1', r'\theta_2', r'\omega_1', r'\omega_2', r'LLF']
fig, axes = plt.subplots(4, 2, figsize=(10, 10))
plt.suptitle('KDE Plot of Garch-Midas Parameters', fontsize=12, weight='bold')
plt.subplots_adjust(left=0.125, right=0.9, top=0.935, bottom=0.110)
plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.25, hspace=0.3)
for index, column in enumerate(columns):
i = index // 2
j = index % 2
# print(index, i, j)
sns.kdeplot(gm_p.values[:, index], linewidth=1, linestyle='solid',
fill=True, color='#DC143C', label=f'column1 ${column}$', ax=axes[i][j])
sns.kdeplot(gm_p.values[:sz_china, index], linewidth=1, linestyle='solid', legend=True,
fill=True, color='teal', label=f'column2 ${column}$', ax=axes[i][j])
sns.kdeplot(gm_p.values[sz_china:, index], linewidth=1, linestyle='solid',
fill=True, color='#6495ED', label=f'column3 ${column}$', ax=axes[i][j])
sns.rugplot(gm_p.values[:, index], color='#DC143C', alpha=0.5, ax=axes[i][j])
sns.rugplot(gm_p.values[:sz_china, index], color='teal', alpha=0.5, ax=axes[i][j])
sns.rugplot(gm_p.values[sz_china:, index], color='#6495ED', alpha=0.5, ax=axes[i][j])
# mean vline
axes[i][j].axvline(np.mean(gm_p.values[:, index]), linewidth=1, color='#DC143C')
axes[i][j].axvline(np.mean(gm_p.values[:sz_china, index]), linewidth=1, color='teal')
axes[i][j].axvline(np.mean(gm_p.values[sz_china:, index]), linewidth=1, color='#6495ED')
# legend
axes[i][j].legend(loc=0, frameon=False, prop={'style': 'italic', 'weight': 'bold'})
axes[i][j].autoscale(enable=True, axis='x', tight=False)
# x-axis, y-axis, font
for size in axes[i][j].get_xticklabels(): # 获取x轴上所有坐标,并设置字号
size.set_fontname('Times New Roman')
for size in axes[i][j].get_yticklabels(): # 获取x轴上所有坐标,并设置字号
size.set_fontname('Times New Roman')
# ticker
axes[i][j].tick_params(axis='both', which='major', labelsize=9, bottom=True, left=True)
plt.tight_layout()
plt.savefig('./figures/kde of garch-midas parameters.pdf')
plt.close()