相关疑难解决方法(0)

模拟已弃用的seaborn distplots

Seaborndistplot现已弃用,并将在未来版本中删除。建议使用histplot(或displot作为图形级图)作为替代方案。distplot但和之间的预设有所不同histplot

from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns

x_list = [1, 2, 3, 4, 6, 7, 9, 9, 9, 10]
df = pd.DataFrame({"X": x_list, "Y": range(len(x_list))})

f, (ax_dist, ax_hist) = plt.subplots(2, sharex=True)

sns.distplot(df["X"], ax=ax_dist)
ax_dist.set_title("old distplot")
sns.histplot(data=df, x="X", ax=ax_hist)
ax_hist.set_title("new histplot")

plt.show()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

那么,我们如何配置histplot来复制已弃用的输出distplot

python matplotlib histogram kernel-density seaborn

4
推荐指数
1
解决办法
3261
查看次数

标签 统计

histogram ×1

kernel-density ×1

matplotlib ×1

python ×1

seaborn ×1