How it works...

Here is the explanation of the preceding code:

  • qApp = QtWidgets.QApplication(sys.argv) invokes the Qt GUI application. It expects sys.argv as arguments, even if it is empty
  • window = QtWidgets.QMainWindow() defines the main window in which the figure is displayed
  • fig = Figure(figsize=(8, 6), dpi=100) defines the figure
  • canvas = FigureCanvas(fig) defines the canvas and attaches the figure to it
  • toolbar = NavigationToolbar(canvas, window) defines the toolbar for the GUI and attaches it to the main window and canvas
  • Step 3 defines the axes and data for the polar plot, and plots the polar graph
  • def update(): is the callback function for the slider and exactly the same as in the preceding recipe
  • n_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) ...

Get Matplotlib 3.0 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.