我怎样才能将 kde 的带宽传递给 seaborn 的 distplot?

How can I hand a to bandwidth for the kde to seaborn's distplot?

我正在使用 sns.distplot hist=True 和 kde=True。这工作正常但对于某些数据集(例如,如果它们仅包含离散值),核密度估计线是锯齿形的,考虑到下面的直方图是平滑的,这看起来很奇怪。手动调整 kde 带宽应该可以解决这个问题,但我如何为 sns.distplot 设置这个?该文档没有说明任何内容,适用于 sns.kdeplot 的 "bw" 参数不存在。我怎样才能阻止它弯曲?

您可以在 seaborn distplot 中使用带有可选参数“kde_kws”的带宽选项 (bw) 来设置所需的带宽。

例如: g = g.map(sns.distplot, "值", kde_kws={'bw':0.1})