Python 子地块边界外的箱线图

Python 子地块边界外的箱线图,python,matplotlib,seaborn,boxplot,Python,Matplotlib,Seaborn,Boxplot,我正在编写一个代码来显示两个堆叠的子地块,代码如下: df['date'] = pd.to_datetime(df['date']) df['month_year'] = pd.to_datetime(df['date']).dt.to_period('M') df['year'] = pd.to_datetime(df['date']).dt.year # we don't need 2017 because our data is 2014-->201

我正在编写一个代码来显示两个堆叠的子地块,代码如下:

    df['date'] = pd.to_datetime(df['date'])
    df['month_year'] = pd.to_datetime(df['date']).dt.to_period('M')
    df['year'] = pd.to_datetime(df['date']).dt.year

    # we don't need 2017 because our data is 2014-->2016
    df = df[df['year'] != 2017]
    fig, axarr = plt.subplots(2, 1)
    sns.boxplot(x='year', y='demand', data=df, ax=axarr[0])
    sns.boxplot(x='year', y='civilians_rank', data=df, ax=axarr[1])
    # df.boxplot(by='month_year', column='demand', ax=axarr[0])
    # df.boxplot(by='month_year', column='civilians_rank', ax=axarr[1])
    axarr[0].tick_params(axis='x', rotation=45)
    axarr[1].tick_params(axis='x', rotation=45)

    fig = plt.gcf()
    # fig.set_size_inches(18, 14)
    fig.tight_layout()
    plt.xticks(rotation=45)
但是,长方体打印高度大于子地块大小,如下所示:


正如您所看到的,第二个子图裁剪了一些箱线图。我尝试使用
fig.set\u size\u inches(18,14)
以及中的建议来增加体形尺寸,但没有任何改变。

我认为这里没有任何裁剪。你的情节中可能没有任何威士忌,如果
1
是最低可能的等级,
4
是最高可能的等级,这就很有意义了。@ImportanceOfBeingErnest哇,我错过了,非常感谢你。