我在 Jupyter 实验室笔记本中使用 matplotlib 和
%matplotlib widget
。当我显示图形时,其上方会显示“图 1”。我怎样才能摆脱它?
我发现
plt.figure(num='', frameon=False)
确实显示了一个没有这个前缀的图形,但是它不是交互式的,我以后无法更新其内容(这就是我首先使用上述魔法的原因)。
您可以在制作交互式绘图后将其添加到下一个单元格中以至少更改为空:
#based on https://stackoverflow.com/a/73802955/8508004
man = plt.get_current_fig_manager()
man.set_window_title(" ")
不过,我还没有想出将其包含在同一个单元格中的方法。