【问题标题】:How to remove the window title of a matplotlib figure when using the widget backend使用小部件后端时如何删除 matplotlib 图的窗口标题
【发布时间】:2020-04-08 02:38:29
【问题描述】:

我使用小部件后端将交互式 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

【问题讨论】:

    标签: python matplotlib jupyter-notebook ipywidgets


    【解决方案1】:

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

    %%html
    <style>
    div.jupyter-widgets.widget-label {display: none;}
    </style>
    

    【讨论】:

    • 谢谢!在此期间我无法解决它,所以它仍然有用
    • 对此我感到非常高兴。如果这解决了您的问题,请不要忘记接受答案。
    • 我意识到这不仅会删除标题,还会删除光标的 x 和 y 坐标,如下图所示。有没有办法保留它们?
    猜你喜欢
    • 2016-08-14
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    相关资源
    最近更新 更多