- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 sns.histplot() 而不是 sns.distplot() 因为我在 colab 中收到以下消息:
FutureWarning:
distplot
is a deprecated function and will be removedin a future version. Please adapt your code to use eitherdisplot
(afigure-level function with similar flexibility) orhistplot
(an axes-level function for histograms).
代码:
import pandas as pd
import seaborn as sns
df = sns.load_dataset('tips')
sns.histplot(df['tip'], kde=True, kde_kws={'fill' : True});
我在 sns.histplot()
中传递 kde_kws
参数时出错:
TypeError: init() 得到了一个意外的关键字参数“fill”
最佳答案
来自 the documentation kde_kws=
旨在传递“控制 KDE 计算的参数,如在 kdeplot() 中”。这些参数是哪些参数并不完全明确,但它们似乎是 bw_method=
和 bw_adjust=
之类的参数,它们改变了 KDE 的计算方式,而不是显示方式。如果你想改变 KDE 绘图的外观,你可以使用 line_kws=
,但是,顾名思义,KDE 仅由一条线表示,因此无法填充。
如果您同时想要直方图和填充的 KDE,则需要在同一轴上组合 histplot()
和 kdeplot()
sns.histplot(df['tip'], stat='density')
sns.kdeplot(df['tip'], fill=True)
关于seaborn - 如何为 seaborn.histplot() 使用 kde_kws 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65623867/
我是一名优秀的程序员,十分优秀!