将 Seaborn distplot 代码更新到 0.11 版 [英] Updating Seaborn distplot code to version 0.11

查看:83
本文介绍了将 Seaborn distplot 代码更新到 0.11 版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 distplot 绘制直方图

sns.distplot(a, color="red", label="100% Equities")

在 Seaborn 0.11 或更高版本下运行它会产生警告,distplot 将被弃用并使用 displot 代替.

使用 displot 作为直接替换(只需将函数名称从 distplot 更改为 displot)不会产生相同的直方图.

什么是替换代码?

解决方案

使用

  • histplot 而不是 distplot
  • 并添加关键字 args kde=True, stat=density", linewidth=0

所以:

sns.histplot(a, color=red", label=100% Equities", kde=True, stat=密度", linewidth=0)

替换

sns.distplot(a, color="red", label="100% Equities")

Using distplot to plot a histogram

sns.distplot(a, color="red", label="100% Equities")

and running this under Seaborn version 0.11 or greater produces a warning that distplot will be deprecated and to use displot instead.

Using displot as a direct replacement (simply changing the function name from distplot to displot) does not produce the same histogram.

What is the replacement code?

解决方案

Use

  • histplot instead of distplot
  • and add the keyword args kde=True, stat="density", linewidth=0

So:

sns.histplot(a, color="red", label="100% Equities", kde=True, stat="density", linewidth=0)

replaces

sns.distplot(a, color="red", label="100% Equities")

这篇关于将 Seaborn distplot 代码更新到 0.11 版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆