[英]Reset (or assign a value) to RadioButton in matplotlib
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 ).我在绘图上有一个滑块和一个 RadioButton(非常类似于这里的一个节目: 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.
如果我更改 Amp 和 Freq 滑块,然后点击重置,绘图将返回其初始值。 However, if I change red to blue and then hit reset, it stays on blue.
但是,如果我将红色更改为蓝色然后点击重置,它会保持蓝色。 How can I reset a RadioButton?
如何重置 RadioButton? I use the following to reset the slider:
我使用以下方法重置滑块:
def resetplt(event)
svalueM.reset()
where svalueM is defined as:其中 svalueM 定义为:
svalueM = Slider(slider_M, 'M', smin, smax, valinit=sinit)
Add添加
radio.set_active(0)
to your reset function.到您的重置功能。
replace 0
with whatever value was set as active=
in the creation of the RadioButtons将
0
替换为在创建 RadioButtons 时设置为active=
任何值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.