python - 使用小部件后端时如何删除 matplotlib 图形的窗口标题

标签 python matplotlib jupyter-notebook ipywidgets

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

相关文章:

python - 使用 nginx/gunicorn 上传 Django 文件 - 媒体权限

python - 如何标准化热图

python - 如何绘制尖角?

jupyter-notebook - 如何为anacadona安装漂亮的汤?

python - 如何在 python 中迭代/操作类对象列表(分散网络模拟中的节点爬行)

python - 为什么 tf.Variable 可迭代但不能迭代

python - 如何使用python在控制台中获取键盘事件

python - 如何在 seaborn lineplot 上绘制虚线?

jupyter-notebook - Jupyter 链接到部分

jupyter-notebook - 如何为 IJulia Jupyter 笔记本设置 Julia 环境?