title: How to use Radio Buttons to control a pie chart matplotlib?
body: <p>I have a  little issue in my code and I hope someone will have an idea to help me. So, I have created a pie chart and, with RadioButtons, I would like to 'control' the 'explode parameter'. Expected result : we have a pie chart, we have Radiobutton and when we click on a radio button, in the pie chart the 'serie' that matches with the Radiobutton clicked is pulled out (thanks to 'explode') and we can do that as long as we want.</p>
  <p>My problem : I have created the Radio Buttons, and when they are clicked, it opens a new window with the expected result but I would like to have the pie chart and the Radiobuttons in the same window.</p>
  <p>My code just below :</p>
  <pre><code>import matplotlib.pyplot as plt
  from matplotlib.widgets import RadioButtons
  rax = plt.axes([0.05, 0.7, 0.15, 0.15])
  radio = RadioButtons(rax, ('0-4 ans', '5-10 ans', '11-13 ans', '14-17 ans'))
  def explode_function(label):
      labels = '0-4 ans', '5-10 ans', '11-13 ans', '14-17 ans'
      sizes = [17.4, 25.7, 18.6, 38.3]
      explode = (0, 0, 0, 0)  # only &quot;explode&quot; the 2nd slice (i.e. 'Hogs')
      fig1, ax = plt.subplots()
      if label == '0-4 ans':
          explode = (0.15, 0, 0, 0)
      elif label == '5-10 ans':
          explode = (0, 0.15, 0, 0)
      elif label == '11-13 ans':
          explode = (0, 0, 0.15, 0)
      elif label == '14-17 ans':
          explode = (0, 0, 0, 0.15)
      ax.pie (sizes, explode=explode, labels=labels, autopct='%1.1f%%',
          shadow=True, colors=['lightblue', 'lightgreen', 'salmon', 'lightgray'])
      plt.show()
  radio.on_clicked(explode_function)
  plt.show()```
  
  Thanks a lot, and good evening 
  </code></pre>