-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
It seems that in the jupyter notebook, %matplotlib inline doesn't play nice with the new ipywidgets 6.0 @interact anymore. As best as I can tell, the inline backend waits until the cell is completely finished before sending the display_data message with the image. In ipywidgets 6.0, we've changed how interacts work to be more specific about the outputs we capture - we capture output messages sent during execution of the function, and display those in the interactive output. However, since (it appears that) the matplotlib inline backend sends its image after the function is executed, we just get a huge series of images in the output area of the cell.
import matplotlib.pyplot as plt
from ipywidgets import interact
%matplotlib inline
x = [1,2,5,4,3]
@interact(n=(2,5))
def f(n):
plt.plot(x[:n])This issue is about starting the discussion to see if there's a way for us to come up with a good solution that works well with the inline backend (which is useful) and also works well with the ipywidgets interact.
For example, if there was a way to tell the inline backend to send its image immediately and not after a cell finished executing, that might be enough. This code works, for example (without the inline backend being enabled)
import matplotlib.pyplot as plt
from ipywidgets import interact
x = [1,2,5,4,3]
@interact(n=(2,5))
def f(n):
plt.plot(x[:n])
plt.show()
CC @SylvainCorlay, @tacaswell.