Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter, Interactive Matplotlib: Hide the toolbar of the interactive view

I am starting using the interactive plotting from Matplotlib:

%matplotlib notebook
import matplotlib.pyplot as plt
fig, axes = plt.subplots(1, figsize=(8, 3))
plt.plot([i for i in range (10)],np.random.randint(10, size=10))     
plt.show()

enter image description here

Anyone knows if there is a way to hide the toolbars of the interactive mode?

like image 480
Radar Avatar asked Jan 30 '17 02:01

Radar


2 Answers

Use the magic %matplotlib ipympl with canvas. toolbar_visible=False. To prevent double-appearence of figure, use plt. ioff() while instantiate figure:

import matplotlib.pyplot as plt

plt.ioff()
fig, ax = plt.subplots()
plt.ion()

fig.canvas.toolbar_visible = False
display(fig.canvas)

It's a little bit doubly, but so you know how to play with plt

Edit: Haven't mind you on jupyter. This works on jupyterlab

like image 169
Micky Avatar answered Sep 20 '22 15:09

Micky


I disabled the interactive mode buttons and toolbar with some python generated css. Run the following in one of the notebook cells:

%%html
<style>
.output_wrapper button.btn.btn-default,
.output_wrapper .ui-dialog-titlebar {
  display: none;
}
</style>

Unfortunately there's no good css selectors on the buttons, so I've tried to use as specific selector as possible, though this may end up disabling other buttons that you might generate in the output cell. Indeed, this approach affects all output cells in the notebook.

like image 45
Freddie Page Avatar answered Sep 18 '22 15:09

Freddie Page