Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disable matplotlib toolbar

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.

like image 680
dimka Avatar asked Dec 18 '12 23:12

dimka


3 Answers

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

like image 147
Doughy Avatar answered Oct 30 '22 11:10

Doughy


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
like image 41
Paloha Avatar answered Oct 30 '22 10:10

Paloha


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)
like image 1
skytaker Avatar answered Oct 30 '22 12:10

skytaker