-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ipywidgets with v3.3x #18741
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
Comments
There's probably a bug a here, one that I don't understand, but you can work around this by using ipywidgets in a more manual fashion. The issue is probably (maybe?) something to do with a weird sideeffect of using import numpy as np
import ipywidgets as widgets
import matplotlib.pyplot as plt
from IPython.display import display
%matplotlib notebook
class MWE:
def __init__(self):
self.fig, self.ax = plt.subplots(1, 1)
self.ax.set_xlim([-5, 105])
self.ax.set_ylim([-500, 10500])
self.create_widget()
self.draw()
def create_widget(self):
self.slider = widgets.IntSlider(value=50, min=0, max=100)
self.slider.observe(self.update_value, names='value')
display(self.slider)
self.value = 0
def draw(self):
self.ax.plot(self.value, self.value**2, 'o')
def update_value(self, change):
self.value = change['new']
self.draw()
MWE() If you're including matplotlib in a layout with ipywidgets you may also want to use |
If I run that code and try to use the pan or zoom tools I get a lot of
which makes me think that something has gone sideways with the display logic (and our js hacking and the ipywidget display work are colliding) which results in the comm (how the JS front end talks to the python backend) being torn down prematurely. |
Thanks @ianhi , that works for this example. However, the real examples has various sliders, dropdowns, buttons, that are aligned horizontally etc. Does that approach work for a complex setup? |
@prisae yup it should. You may need to be careful to use one of the ipywidgets layouts either the highlevel
|
OK, that is definitely one route. But it would include rewriting the GUI to some extent. I am sure that there are other "Jupyter-Apps" that will break when updating to matplotlib v3.3, so it would be nice to find out what is breaking it... |
The other thing to note is that if you change |
Ha, fantastic, thanks! I tried Thanks. For me that is solved. Not sure if you want to keep the issue open though to track the problem down or not. |
There are issues switching the backends, typically if you want to restart your kernel too. |
My bad. |
This is a duplicate of #18638, and will be fixed in 3.3.3. |
Bug report
Bug summary
Interactive code (Jupyter Notebook using
%matplotlib notebook
) worked up to v3.2.x, stops working for v3.3.x. Tested on Firefox and Chrome.Code for reproduction
Actual outcome
Just an empty figure, moving the slider has no effect, no warning thrown either.
Expected outcome
More and more dots should be printed when moving the slider.
Matplotlib version
Installed with
mamba
fromconda-forge
.It might be related to #18481, but it happens for Firefox and Chrome on my machine. Also, the mentioned workaround (#18481 (comment)) does not help.
The text was updated successfully, but these errors were encountered: