20

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.

1
  • 1
    That works for me. What backend are you using? Commented Dec 19, 2012 at 5:16

5 Answers 5

28

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

Sign up to request clarification or add additional context in comments.

3 Comments

Doesn't work for the nbagg (%matplotlib notebook) backend.
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?
@Taylor I found this block of CSS code in call before invoking the plot seemed to remove the toolbar when using the nbagg (%matplotlib notebook) backend.
5

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

1 Comment

YESSSS this is what I needed
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)

Comments

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)

Comments

-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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.