Skip to main content
 首页 » 编程设计

python之在 df.plot(kind ='hist') 中指定 bean 的数量

2025年01月19日14telwanggs

我有一个数据框df

我想将分组变量的直方图绘制为

df.groupby(['Variable1', 'Variable2']).plot(kind='hist') 

有没有办法指定 bin 的数量?

请您参考如下方法:

在DataFrameGroupBy.hist中使用参数bins :

df.groupby(['Variable1', 'Variable2']).plot.hist(bins=3) 

bins : integer, default 10

Number of histogram bins to be used