我使用一些由Python生成的CSS禁用了交互模式按钮和工具栏。 在笔记本的一个单元格中运行以下内容:
%%html
<style>
.output_wrapper button.btn.btn-default,
.output_wrapper .ui-dialog-titlebar {
display: none;
}
</style>
很不幸,这些按钮上没有好的css选择器,因此我尽可能使用了最具体的选择器,但这可能会禁用您在输出单元格中生成的其他按钮。实际上,这种方法会影响笔记本中的所有输出单元格。
import matplotlib.pyplot as plt
plt.ioff()
fig, ax = plt.subplots()
plt.ion()
fig.canvas.toolbar_visible = False
display(fig.canvas)
这有点重复,但是你需要知道如何使用plt进行操作。
编辑:我没有在jupyter上考虑过你。这在jupyterlab上可行。
%matplotlib inline
而不是%matplotlib notebook
。 - swatchai