How it works...

Here is the explanation for the preceding code:

  • The first two steps define the figure using plt.figure(), axes, and data, and plots the polar graph on the figure.
  • window = fig.canvas.manager.window gets access to the wxPython application through its window.
  • def update(event): is the callback function for the wx.Slider() widget. Here, we have to pass the event argument to the function:
    • n=n_slider.GetValue() gets the current value of the slider. Please note the difference in syntax compared to what we had for Tkinter.
    • The remaining three steps of this function are exactly the same as with Tkinter.
  • n_slider = wx.Slider(window, wx.ID_ANY, 3, 3, 10, size=(250,10), style=(wx.SL_AUTOTICKS | wx.SL_HORIZONTAL | wx.SL_LABELS))

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.