Reset (or assign a value) to RadioButton in matplotlib

744 Views Asked by At

I have a slider and a RadioButton on a plot (very similar to the one show here: https://matplotlib.org/3.1.1/gallery/widgets/slider_demo.html). If I change the Amp and Freq sliders and then hit reset, the plot goes back to its initial values. However, if I change red to blue and then hit reset, it stays on blue. How can I reset a RadioButton? I use the following to reset the slider:

def resetplt(event)
    svalueM.reset()

where svalueM is defined as:

svalueM = Slider(slider_M, 'M', smin, smax, valinit=sinit)
1

There are 1 best solutions below

5
Diziet Asahi On BEST ANSWER

Add

radio.set_active(0)

to your reset function.

replace 0 with whatever value was set as active= in the creation of the RadioButtons