Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
When a Slider is created inside a function, it is typically non-responsive (does not react to the mouse):
from matplotlib import pyplotfrom matplotlib.widgets import Slidersliders = []def open_fig_with_slider(): pyplot.figure() slider = Slider(pyplot.axes([0.25, 0.1, 0.65, 0.03]), 'Slider', 0, 1, valinit=0.5) # sliders.append(slider)open_fig_with_slider()pyplot.show() # The slider is unresponsive unless append above is un-commented
The problem appears to be fixed by keeping a reference to the slider. The closest thing I've found in the documentation is that a canvas only keeps weak references to itscallbacks (http://matplotlib.org/users/event_handling.html). However, the connection with sliders is not so obvious—if there is any.
If I'm not mistaken, this behavior is not documented, so it would be nice to add it to the documentation, if it is normal.