我使用小部件后端将交互式 matplotlib 图形嵌入到 ipywidgets.GridBox
中。
窗口标题占用了太多空间,我想将其删除。
使用plt.figure(' ')
它变得不可见,但即使使用fig.tight_layout()
,空间仍然被保留并占用我布局中无用的空间。
下面是一个最小的示例。
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但没有后端特定选项的完整列表。 在这篇相关文章中,给出了笔记本后端的解决方案。 what is the official name of this title bar from matplotlib, how to hide it
最佳答案
我的回答有点晚了,但也许其他人也感兴趣。对于这个特殊的后端,可以通过以下方式使标题不可见
%%html
<style>
div.jupyter-widgets.widget-label {display: none;}
</style>
关于python - 使用小部件后端时如何删除 matplotlib 图形的窗口标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59342961/