14

Is there a way to disable/hide matplotlib Toolbar that shows up on the bottom?

I'd tried something like this:

import matplotlib as mpl
mpl.rcParams['toolbar'] = 'None'

but unfortunately that didn't work.

tacaswell
  • 79,602
  • 19
  • 200
  • 189
dimka
  • 3,881
  • 11
  • 29
  • 36

5 Answers5

20

Make sure to call mpl.rcParams['toolbar'] = 'None' before you instantiate any figures.

sodd
  • 11,544
  • 3
  • 51
  • 60
Doughy
  • 3,925
  • 6
  • 33
  • 38
  • 2
    Doesn't work for the nbagg (`%matplotlib notebook`) backend. – Taylor Aug 17 '17 at 13:11
  • 1
    Is the toolbar the thing at the top of the figure window that has the zoom/pan buttons in it, or the display at the bottom of the figure window that displays x- and y-coordinates of the cursor? Is there a separate name for these display widgets? – cxrodgers Jan 31 '18 at 22:44
  • @Taylor I found [this block of CSS code](https://stackoverflow.com/a/46735198/8508004) in call before invoking the plot seemed to remove the toolbar when using the nbagg (`%matplotlib notebook`) backend. – Wayne Mar 17 '22 at 16:10
4

If you are in Jupyter using %matplotlib widget (ipympl) you can do:

fig.canvas.toolbar_visible = False

You can also disable header and footer with:

fig.canvas.header_visible = False
fig.canvas.footer_visible = False
Paloha
  • 472
  • 5
  • 12
1

Alternatively, you can hide the toolbar:

QToolBar.hide()

or

QToolBar.setVisible(False)

Obviously this will only work with a Qt backend. To expand on this answer, given the figure fig:

First, if using Qt5:

from PyQt5 import QtWidgets 

Otherwise:

from PyQt4 import QtGui as QtWidgets 

Then:

try:
    win = fig.canvas.manager.window
except AttributeError:
    win = fig.canvas.window()
toolbar = win.findChild(QtWidgets.QToolBar)
toolbar.setVisible(False)
cbrnr
  • 1,261
  • 1
  • 11
  • 24
skytaker
  • 3,704
  • 1
  • 20
  • 29
0

To expand on bejota's answer:

Obviously this will only work with a Qt backend. To expand on this answer, given the figure fig:

First, if using Qt5:

from PyQt5 import QtWidgets 

Otherwise:

from PyQt4 import QtGui as QtWidgets 

Then:

toolbar = win.findChild(QtWidgets.QToolBar)
toolbar.setVisible(False)
try:
    win = fig.canvas.manager.window
except AttributeError:
    win = fig.canvas.window()
toolbar = win.findChild(QtWidgets.QToolBar)
toolbar.setVisible(False)
Erotemic
  • 4,201
  • 4
  • 32
  • 68
-2

you can go to C:\Python27\Lib\site-packages\matplotlib\mpl-data , there you will see the file named matplotlibrc, open the file and you will find a line like:

#toolbar      : toolbar2# None | toolbar2  ("classic" is deprecated)

uncomment that line and place None after the colon like:

toolbar      : None# None | toolbar2  ("classic" is deprecated) and save the file,

I guess after you can disable the toolbar in graphs plotted by matplotlib.

sodd
  • 11,544
  • 3
  • 51
  • 60
Vivek Saurav
  • 2,195
  • 4
  • 24
  • 44