【问题标题】:Making grouped histograms bigger in Python在 Python 中使分组直方图更大
【发布时间】:2019-05-06 23:25:14
【问题描述】:

我正在根据this question 在 python 中绘制一些分组直方图,但我正在尝试绘制更多直方图并使它们更大。

举个例子:

from pandas import DataFrame
import numpy as np
x = ['A']*300 + ['B']*400 + ['C']*300 + ['D']*400 + ['E']*200 + ['F']*500 + 
['G']*400 + ['H']*500 + ['I']*300
y = np.random.randn(3300)
df = DataFrame({'Letter':x, 'N':y})
grouped = df.groupby('Letter')

然后我在 Jupyter 中像这样绘制:

%matplotlib inline
df['N'].hist(by=df['Letter'])

但情节非常小。如何增加大小以填满页面?

【问题讨论】:

    标签: python pandas numpy histogram


    【解决方案1】:

    没那么难:

    df['N'].hist(by=df['Letter'], figsize = (16,18))
    

    【讨论】:

    • 注意:figsize 后面的值必须在括号内,表示(width, heigth)。另一种方法是在df['N'].hist() 之前加上plt.figure(figsize=(16,8)) 的一行,如果您之前导入了import matplotlib.pyplot as plt,即。
    猜你喜欢
    • 1970-01-01
    • 2017-08-02
    • 2020-03-26
    • 2020-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-10
    • 2017-06-07
    相关资源
    最近更新 更多