Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zoom and move buttons broken for mpl 3.7.0 #516

Closed
Linusnie opened this issue Feb 14, 2023 · 12 comments · Fixed by #517
Closed

zoom and move buttons broken for mpl 3.7.0 #516

Linusnie opened this issue Feb 14, 2023 · 12 comments · Fixed by #517
Labels

Comments

@Linusnie
Copy link

Linusnie commented Feb 14, 2023

After installing jupyterlab and ipympl I'm able to make plots that can be displayed and resized, but the move and zoom buttons don't work. Tooltips are shown if I hover the cursor over the buttons, but clicking them gives no response.

I also posted in #70 which was closed as outdated

package versions:

ipykernel 6.21.2
ipympl 0.9.2
ipython 8.10.0
ipython-genutils 0.2.0
ipywidgets 8.0.4
jupyter_client 8.0.2
jupyter_core 5.2.0
jupyter-events 0.5.0
jupyter_server 2.2.1
jupyter_server_fileid 0.6.0
jupyter_server_terminals 0.4.4
jupyter_server_ydoc 0.6.1
jupyter-ydoc 0.2.2
jupyterlab 3.6.1
jupyterlab-darkside-ui 0.2.3
jupyterlab-pygments 0.2.2
jupyterlab_server 2.19.0
jupyterlab-widgets 3.0.5

jupyter labextension list returns the following:

jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
jupyter-matplotlib v0.11.2 enabled OK
@jupyter-widgets/jupyterlab-manager v5.0.5 enabled OK (python, jupyterlab_widgets)
@dunovank/jupyterlab_darkside_ui v0.2.3 enabled OK (python, jupyterlab_darkside_ui)

Screenshot from 2023-02-14 23-40-58

@ianhi
Copy link
Collaborator

ianhi commented Feb 14, 2023

@Linusnie are you using ipympl in vscode or in jupyterlab?

@Linusnie
Copy link
Author

@Linusnie are you using ipympl in vscode or in jupyterlab?

I'm using jupyterlab

@ianhi
Copy link
Collaborator

ianhi commented Feb 14, 2023

Ok great. Two follow up questions:

  1. Can you post a gif of you trying to use them?
  2. Can you post the contents of the browser console after trying this here (see how to access https://balsamiq.com/support/faqs/browserconsole/)

@Linusnie
Copy link
Author

sure! There's quite a bit of output in the console, most relevant might be this one: Failed to fetch ipywidgets through the "jupyter.widget.control" comm channel, fallback to fetching individual model state. Reason: Control comm was closed too early? (last image)

screencast
Screenshot from 2023-02-15 10-08-14
Screenshot from 2023-02-15 10-09-08
Screenshot from 2023-02-15 10-09-23

@Linusnie
Copy link
Author

in case it's relevant, things like ipywidgets.IntSlider(10) works and I can interact with no issue

@Linusnie
Copy link
Author

Linusnie commented Feb 15, 2023

Update: looks like the problem is caused by an incompatibility with matplotlib. If I try the same notebook in vs code it prints out the following error message when I try to use the plot (not sure why it doesn't show up when using jupyterlab).

KeyError                                  Traceback (most recent call last)
File ~/workspace/convex_relaxations/venv3.10/lib/python3.10/site-packages/ipympl/backend_nbagg.py:279, in Canvas._handle_message(self, object, content, buffers)
    276     self.manager.handle_json(content)
    278 else:
--> 279     self.manager.handle_json(content)

File ~/workspace/convex_relaxations/venv3.10/lib/python3.10/site-packages/matplotlib/backends/backend_webagg_core.py:462, in FigureManagerWebAgg.handle_json(self, content)
    461 def handle_json(self, content):
--> 462     self.canvas.handle_event(content)

File ~/workspace/convex_relaxations/venv3.10/lib/python3.10/site-packages/matplotlib/backends/backend_webagg_core.py:266, in FigureCanvasWebAggCore.handle_event(self, event)
    263 e_type = event['type']
    264 handler = getattr(self, 'handle_{0}'.format(e_type),
    265                   self.handle_unknown_event)
--> 266 return handler(event)

File ~/workspace/convex_relaxations/venv3.10/lib/python3.10/site-packages/matplotlib/backends/backend_webagg_core.py:293, in FigureCanvasWebAggCore._handle_mouse(self, event)
    290 button = event['button'] + 1
    292 e_type = event['type']
--> 293 modifiers = event['modifiers']
    294 guiEvent = event.get('guiEvent')
    295 if e_type in ['button_press', 'button_release']:

KeyError: 'modifiers'

After downgrading matplotlib using python -m pip install matplotlib==3.6.2 zooming and moving works as usual

@ianhi ianhi changed the title zoom and move buttons not working in jupyterlab zoom and move buttons broken for mpl 3.7.0 Feb 15, 2023
@ianhi ianhi added the bug label Feb 15, 2023
@ianhi
Copy link
Collaborator

ianhi commented Feb 15, 2023

Ahh indeed broken for the new matplotlib. Thank you for reporting!

f I try the same notebook in vs code it prints out the following error message when I try to use the plot (not sure why it doesn't show up when using jupyterlab).

You can see the errors by going View> Show Log Console and changing thelevel to info

@ianhi
Copy link
Collaborator

ianhi commented Feb 15, 2023

I think the breakage is caused by matplotlib/matplotlib#23473 which requires us to add modifiers to events from javascript side, because we don't rely on mpl.js we did pick up the changes from that side, only the python side.

@ianhi
Copy link
Collaborator

ianhi commented Feb 15, 2023

Thanks again for reporting @Linusnie ! The fix has been merged, trying to remember how to make a release now - once that's done version 0.9.3 and up should work with latest matplotlib

@ianhi
Copy link
Collaborator

ianhi commented Feb 15, 2023

@Linusnie should be fixed in the now release version 0.9.3

@Linusnie
Copy link
Author

@ianhi awesome! thanks for the quick response

@Sciroccogti
Copy link

Is it really fixed? ipympl=0.9.3 with matplotlib=3.7.0 still get the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants