首页 > 解决方案 > 使用 Seaborn `displot`(不是 `distplot`)在同一图表上绘制多个直方图

问题描述

Seaborndistplot已被弃用。

我得到distplot下图

在此处输入图像描述

使用此代码:

import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot(random.normal(loc=177.8, scale=10.2, size=1000), kde=True)
sns.distplot(random.normal(loc=165.1, scale=8.9, size=1000), kde=True)

plt.show()

请问我如何达到同样的效果displot?如果我只是替换displotdistplot则直方图将单独显示。

标签: pythonmatplotlibseaborn

解决方案


您想使用 displot 有什么特别的原因吗?使用histplot可以实现您的目标。


推荐阅读