Take the 2-minute tour ×

I have a very simple pyqt4 application that embeds a MatPlotLib figure. I am embedding the matplotlib figure through the MatplotlibWidget and I created the interface through the QtDesigner along with pyuic4.

I would like to provide the user access to the toolbar for interactive navigation. But, despite their nice example on GTK, I can't seem to get it to work for pyQt. It mentions examples, but the example for QT4 provided does not include the toolbar.

I appreciate any help with this.

This question is similar, but does not quite address what I need and I have not been able to adapt it.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

There is no toolbar widget in QtDesigner, but you can add the toolbar by code:

Here is the example, the plot_layout is a QVBoxLayout designed by QtDesigner, and plot_canvas is the MatplotlibWidget widget.

import numpy as np
from PyQt4.QtCore import Qt
from PyQt4.QtGui import *
from matplotlib.backends.backend_qt4 import NavigationToolbar2QT as NavigationToolbar
from plot_dialog2 import Ui_Form

class PlotDialog(QWidget, Ui_Form):
    def __init__(self):
        self.navi_toolbar = NavigationToolbar(self.plot_canvas, self)

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    dialog = PlotDialog()
share|improve this answer
Thank you, this provided what I needed to get it working. –  TimothyAWiseman Apr 27 '12 at 20:13
add comment

Your Answer


