Seaborn distplot的权重选项? [英] weights option for seaborn distplot?

查看:135
本文介绍了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屋!

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