简体   繁体   中英

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

I use the widget backend to embed an interactive matplotlib figure in an ipywidgets.GridBox . The window title takes up too much space and I want to remove it. With plt.figure(' ') it becomes invisible but even with fig.tight_layout() the space is still reserved and takes up useless space in my layout. Below is a minimal example.

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)

I found a few examples here but no complete list of backend specific options. In this related post a solution for the notebook backend is given. what is the official name of this title bar from matplotlib, how to hide it

My answer is a little late but maybe someone else is interested, too. For this special backend the title can be made invisible by

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM