使用小部件后端时如何删除 matplotlib 图的 window 标题

How to remove the window title of a matplotlib figure when using the widget backend

我使用小部件后端在 ipywidgets.GridBox 中嵌入交互式 matplotlib 图。 window 标题占用太多space,我想删除它。 使用 plt.figure(' ') 它变得不可见,但即使使用 fig.tight_layout() space 仍然保留并且在我的布局中占用无用的 space 。 下面是一个最小的例子。

import matplotlib.pyplot as plt
%matplotlib widget
plt.ioff()
fig = plt.figure('remove the title')
plt.plot([0,1],[0,1])
fig.tight_layout()
display(fig.canvas)

我找到了一些示例 here 但没有后端特定选项的完整列表。 在这个相关的 post 中给出了笔记本后端的解决方案。

我的回答有点晚了,但也许其他人也有兴趣。对于这个特殊的后端,可以通过

使标题不可见
%%html
<style>
div.jupyter-widgets.widget-label {display: none;}
</style>