为何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()

换成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()

数据本身无问题,已添加%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
相关产品推荐
相关产品推荐

