-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
matplotlib>=3.3.2
breaks ipywidgets.interact
#18638
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
This has something to do with #18454. I guess interact replaces the |
interesting, yes, if you split the cell just after Really should be able to put both in the same cell. |
Can you try with ipympl? The main source of the problem here is that nbagg is not aware of ipywidgets (we just grab the DOM and shove a bunch of divs and js into it!). If you use ipympl does it work better (ipympl is based on widgets and hence plays much nice with them). |
Just did TypeError Traceback (most recent call last)
~/py2/envs/py37/lib/python3.7/site-packages/ipympl/backend_nbagg.py in _handle_message(self, object, content, buffers)
208 def _handle_message(self, object, content, buffers):
209 # Every content has a "type".
--> 210 if content['type'] == 'closing':
211 self._closed = True
212 elif content['type'] == 'initialized':
TypeError: string indices must be integers |
Can you please report that to ipympl? |
In JavaScript, the event handlers are called for both the element and also bubbled up from any children. If the Matplotlib figure is the only thing in the output, that's fine, as closing the figure when one of the `canvas` or `div`s clears is the same as when the `OutputArea` is cleared. However, if there are other outputs, such as widgets, we do not want to close the figure if one of them is cleared. As there's no way to clear just the figure output, only close the figure if the _entire_ `OutputArea` div is cleared (i.e., the element we've attached to). Fixes matplotlib#18638.
FYI this seems to be a temporary fix - essentially a decorator around In[2]: +def create_figure(*args, **kwargs):
+ out = ipyw.Output()
+ display(out)
+ with out:
+ return plt.figure(*args, **kwargs)
+
-fig = plt.figure()
+fig = create_figure()
@ipyw.interact(m=ipyw.FloatSlider(value=1, min=-10, max=10, step=0.01))
def update(m):
plt.figure(fig.number, clear=True)
plt.plot([m * x for x in range(-9, 10)]) |
- fixes #10 - fixes matplotlib/matplotlib#18638
- fixes #10 - fixes matplotlib/matplotlib#18638
This still needs fixing. |
lol cross-org cross-repo close commands are now a thing? Interesting. |
Bug report
Bug summary
Using
ipywidgets.interact
to update a figure works as expected inmatplotlib<=3.3.1
, but fails inmatplotlib==3.3.2
.I don't think this is an
ipywidgets
issue since downgradingmatplotlib
fixes this issue.Code for reproduction
In[1]:
In[2]:
Followed by moving the slider.
Actual outcome
Expected outcome
matplotlib==3.3.1
Matplotlib version
print(matplotlib.get_backend())
): nbAggconda
channelconda-forge
The text was updated successfully, but these errors were encountered: