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
?