Open nvaytet opened 2 years ago
I think the key is in the blocking (or non-blocking) behavior of plt.show()
At the end of the example there are these lines:
plt.show()
selector.disconnect()
When run from a python file the show
is blocking, however in a notebook the show doesn't block execution so the disconnect is run immediately. When I comment out selector.disconnect()
then it works for me.
That was surprisingly difficult to notice. My strategy for figuring it out was to:
%matplotlib nbagg
or %matplotlib qt
- neither workeddisconnect
line and things start workingparts of that strategy are generally applicable to all ipympl bugs. notably trying them in other backends launched form the notebook.
Ok thanks. It seems to work. However, the behaviour of the Shift key is weird, or definitely not like in the Qt window. At first it just seems to do nothing, but then if I release the mouse button, or shift (or both I am not sure anymore), suddenly the polygon moves with the mouse whenever I hold shit (no need to click with the mouse again). The whole thing is quite unusable.
But at least I can see the polygon now (and move the vertices, and everything else). Thanks!
Describe the issue
The PolygonSelector example from the mpl docs works very well in the default Qt backend.
However, using
ipympl
in a notebook, nothing happens. No gray point follows the mouse cursor, nothing is drawn when I click. Just the initial figure with the blue dots. I checked the jupyterlab log console on debug level but there are no errors.I was wondering if it was related to https://github.com/matplotlib/matplotlib/issues/15852, and tried adding
useblit=False
where thePolygonSelector
is created, but this did not help.Versions