You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Matplotlib Pyplot无法显示箱线图而Seaborn可以?

Matplotlib箱线图不显示箱体,Seaborn可正常显示

用Matplotlib批量绘制箱线图时,坐标轴能正常显示,但箱体本身无法渲染出来:

fig, axs = plt.subplots(19, 5, figsize=(20,80))
plt.subplots_adjust(hspace=0.5)
for i in range(len(column_with_null)):
    
    row_loc = i // 5
    col_loc = i % 5
    
    axs[row_loc, col_loc].boxplot(x=data[column_with_null[i]])
    axs[row_loc, col_loc].set_title(column_with_null[i])

plt.show()

Matplotlib实现的执行结果

换成Seaborn实现相同功能,箱线图却能正常显示:

fig, axs = plt.subplots(19, 5, figsize=(20,80))
plt.subplots_adjust(hspace=0.5)
for i in range(len(column_with_null)):
    
    row_loc = i // 5
    col_loc = i % 5
    
    sns.boxplot(data=data[column_with_null[i]], ax=axs[row_loc, col_loc])
    axs[row_loc, col_loc].set_title(column_with_null[i])

plt.show()

Seaborn实现的执行结果

数据本身无问题,已添加%matplotlib inline,在PyCharm中运行结果与上述一致。

有没有人遇到过类似问题?

环境信息

  • conda 23.7.4
  • python 3.9.18
  • matplotlib 3.8.0
  • matplotlib-base 3.8.0
  • matplotlib-inline 0.1.6

内容的提问来源于stack exchange,提问作者tta77

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 03:17:39