ipympl icon indicating copy to clipboard operation
ipympl copied to clipboard

Tearing on interactive ROI

Open thomasaarholt opened this issue 3 years ago • 3 comments

Describe the issue

The plots tear heavily when using interactive rois after creating a new environment (conda create --name testplot ipympl matplotlib jupyterlab).

First noticed in hyperspy/hyperspy#2706, it appears to be a problem with both mpl 3.3/3.4 and ipympl 0.6/0.7.

This matplotlib interactive example results in the following output, both with useblit=True and =False.

image

Versions

 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 04:59:43) [MSC v.1916 64 bit (AMD64)]
ipympl version: 0.7.0
jupyter core     : 4.7.1
jupyter-notebook : 6.3.0
qtconsole        : not installed
ipython          : 7.22.0
ipykernel        : 5.5.3
jupyter client   : 6.1.12
jupyter lab      : 3.0.14
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.3
traitlets        : 5.0.5
Known nbextensions:
  config dir: C:\Users\thomasaar\Miniconda3\envs\testplot\etc\jupyter\nbconfig
    notebook section
      jupyter-matplotlib/extension enabled
      - Validating: ok
      jupyter-js-widgets/extension enabled
      - Validating: ok
JupyterLab v3.0.14
C:\Users\thomasaar\Miniconda3\envs\testplot\share\jupyter\labextensions
        jupyter-matplotlib v0.9.0 enabled ok
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled ok (python, jupyterlab_widgets)

thomasaarholt avatar Apr 13 '21 21:04 thomasaarholt

Is this the same root cause as https://github.com/matplotlib/matplotlib/issues/19116?

ianhi avatar Apr 13 '21 21:04 ianhi

It may be. Just in case that this hint could we of help: when using the ipympl the issue seems to be more prominent than with the notebook backend.

francisco-dlp avatar Apr 17 '21 06:04 francisco-dlp

It looks to me that this is a different issue from matplotlib/matplotlib#19116, because the latter is related to the use of blitting for the webagg backends, and it has been disabled in https://github.com/matplotlib/matplotlib/pull/19762.

The following example works fine in the jupyter notebook but not the jupyterlab, both with the ipympl backend (matplotlib 3.4.2 and ipympl 0.7):

%matplotlib widget
import matplotlib.pyplot as plt
from matplotlib.widgets import RectangleSelector
import numpy as np

values = np.arange(100)

fig = plt.figure()
ax = fig.add_subplot()
ax.plot(values)

span = RectangleSelector(ax, print, interactive=True)

# flush events to get a first draw of the figure before setting the extents
fig.canvas.flush_events()
span.extents = (26, 55, 32, 71)

ericpre avatar May 23 '21 19:05 ericpre