You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a button click event handler, if the callback function includes the input function, the figure automatically closes when the callback function finishes.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnpfig, ax=plt.subplots()
ax.plot(np.random.rand(10))
defonclick(event):
print(f'click: x={event.x}, y={event.y}')
info=input('Enter some information about this point: ') # Comment out this lineprint(info) # Comment out this linecid=fig.canvas.mpl_connect('button_press_event', onclick)
plt.show()
Actual outcome
After a single event and iteration of the onclick callback function, the figure automatically closes without giving the user the opportunity to click on more points.
Screen.Recording.2025-08-12.at.5.17.43.PM.mov
Expected outcome
The figure should remain open and allow the user to click on many points until the user explicitly closes it. This is the standard behavior when the two lines indicated in the MWE related to the input function are commented out.
Bug summary
When using a button click event handler, if the callback function includes the input function, the figure automatically closes when the callback function finishes.
Code for reproduction
Actual outcome
After a single event and iteration of the
onclickcallback function, the figure automatically closes without giving the user the opportunity to click on more points.Screen.Recording.2025-08-12.at.5.17.43.PM.mov
Expected outcome
The figure should remain open and allow the user to click on many points until the user explicitly closes it. This is the standard behavior when the two lines indicated in the MWE related to the
inputfunction are commented out.Screen.Recording.2025-08-12.at.5.23.06.PM.mov
Additional information
No response
Operating system
OS/X
Matplotlib Version
3.10.3
Matplotlib Backend
macosx
Python version
Python 3.13.5
Jupyter version
4.4.5
Installation
pip