ipympl icon indicating copy to clipboard operation
ipympl copied to clipboard

Multicursor disappears when not moving

Open ipcoder opened this issue 4 years ago • 3 comments
trafficstars

Describe the issue

In both JupyterLab and old Notebook MultiCursor not only is blinking when is bing moved, but also completely disappears when mouse stops motion. Same code works fine in QT.

Documentation example may be used for demonstration:


import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import MultiCursor

t = np.arange(0.0, 2.0, 0.01)
s1 = np.sin(2*np.pi*t)
s2 = np.sin(4*np.pi*t)

fig, (ax1, ax2) = plt.subplots(2, sharex=True)
ax1.plot(t, s1)
ax2.plot(t, s2)

multi = MultiCursor(fig.canvas, (ax1, ax2), color='r', lw=1)
plt.show()

Versions

3.8.3 | packaged by conda-forge | (default, Jun  1 2020, 17:43:00) 
[GCC 7.5.0]
ipympl version: 0.6.3
jupyter core     : 4.7.1
jupyter-notebook : 6.2.0
qtconsole        : 5.0.2
ipython          : 7.20.0
ipykernel        : 5.3.4
jupyter client   : 6.1.7
jupyter lab      : 3.0.7
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.2
traitlets        : 5.0.5
Config option `kernel_spec_manager_class` not recognized by `ListNBExtensionsApp`.
Known nbextensions:
  config dir: /home/ilyap/.jupyter/nbconfig
    notebook section
      limit_output/main disabled
      table_beautifier/main disabled
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      qtconsole/qtconsole disabled
      hinterland/hinterland disabled
      snippets_menu/main disabled
      jupyter-datawidgets/extension  enabled 
      - Validating: OK
      collapsible_headings/main disabled
      code_font_size/code_font_size disabled
      addbefore/main disabled
  config dir: /home/ilyap/anaconda3/etc/jupyter/nbconfig
    notebook section
      bqplot/extension  enabled 
      - Validating: OK
      ipyvolume/extension  enabled 
      - Validating: OK
      jupyter-webrtc/extension  enabled 
      - Validating: OK
      jupyter-datawidgets/extension  enabled 
      - Validating: OK
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      jupyter-threejs/extension  enabled 
      - Validating: OK
      k3d/extension  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      qgrid/extension  enabled 
      - Validating: OK
      hide_code/hide_code  enabled 
      - Validating: OK
Config option `kernel_spec_manager_class` not recognized by `ListLabExtensionsApp`.
[W 2021-03-01 14:01:32.364 LabApp] Config option `kernel_spec_manager_class` not recognized by `LabApp`.
JupyterLab v3.0.7
/home/ilyap/anaconda3/share/jupyter/labextensions
        jupyter-matplotlib v0.8.3 enabled OK
        bqplot v0.5.21 enabled OK
        jupyterlab-datawidgets v7.0.0 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /home/ilyap/anaconda3/share/jupyter/lab
        @arbennett/base16-one-dark v0.1.5 enabled OK
        jupyterlab_hidecode v0.1.4 enabled OK


Uninstalled core extensions:
    @aquirdturtle/collapsible_headings

ipcoder avatar Mar 01 '21 12:03 ipcoder

I think this may be related to to https://github.com/matplotlib/matplotlib/issues/19235

One thing to note is that for me at least it seems that it will work, but only after waiting for a bit. Yo can see that something is frozen up because you can't immediately resize either.

Confusingly if I remove the plt.show then it seems to work every time, so there may be an issue with plt.show(). Though it's important to note that you never need plt.show for ipympl. In interactive mode the figure will show automatically, and you can always do display(fig.canvas) to display it.

ianhi avatar Mar 02 '21 05:03 ianhi

I am not sure if it is related to #19235. Here how it looks like:

https://user-images.githubusercontent.com/9642454/109721950-b3743800-7bb4-11eb-998d-477debd3ee36.mp4

ipcoder avatar Mar 02 '21 22:03 ipcoder

Hey @ipcoder I looked into this a bit more and I think there is some sort of sinister interaction going on with the way multicursor handles blitting and the notebook backends (both ipympl and nbagg). I opened https://github.com/matplotlib/matplotlib/issues/19633 about this which I think is where this will need to be resolved as it may involve changes to multicursor. But lets leave this open for now.

ianhi avatar Mar 03 '21 23:03 ianhi