原报错:
File "D:\venv\lib\site-packages\matplotlib\transforms.py", line 653, in union
raise ValueError("'bboxes' cannot be empty")
ValueError: 'bboxes' cannot be empty
报错原因1:
fig.tight_layout()
报错原因2:
plt.savefig(result_path,bbox_inches='tight',pad_inches=0)
总之,类似于缩小图片周围空白区域的语句。
解法一:
这句删掉就好了。
解法二:
回顾代码,是否存在
ax.w_zaxis.line.set_visible(False)
之类的语句。
我的本意是想把z轴轴线设为透明,但是会引发上面的错误。我的背景是白色,所以用
ax.w_zaxis.line.set_color('white')
代替了。
文章讲述了在使用Matplotlib进行图像处理时遇到的错误,主要原因是tight_layout()和savefig()设置导致的空bboxes异常。解决方法包括删除可能导致问题的代码行和调整z轴轴线设置。

被折叠的 条评论
为什么被折叠?



