Seaborn distplot的权重选项? [英] weights option for seaborn distplot?
问题描述
我想在seaborn distplot中有一个权重选项,类似于numpy直方图.如果没有此选项,唯一的选择就是将权重应用于输入数组,这可能会导致大小(和时间)不切实际.
I'd like to have a weights option in seaborn distplot, similar to that in numpy histogram. Without this option, the only alternative would be to apply the weighting to the input array, which could result in an impractical size (and time).
推荐答案
您可以使用hist_kws
参数将权重传递给底层matplotlib的直方图函数,以提供权重,例如:
You can provide weights by passing them to the underlying matplotlib's histogram function using the hist_kws
argument, as:
sns.distplot(..., hist_kws={'weights': your weights array}, ...)
但是请注意,权重将仅传递给基础直方图; kde或distplot
的fit函数都不会受到影响.
Take note though, that the weights will be passed only to the underlying histogram; neither the kde, nor the fit functions of the distplot
will be affected.
这篇关于Seaborn distplot的权重选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!