I'm trying to make use of Interact in a Jupyter Notebook. A bit down on that page, it's stated that
On occasion, you may notice interact output flickering and jumping, causing the notebook scroll position to change as the output is updated. The interactive control has a layout, so we can set its height to an appropriate value (currently chosen manually) so that it will not change size as it is updated.
And I'm experiencing exactly that problem when I'm trying to replicate the example.
The following snippet...
%matplotlib inline
from ipywidgets import interactive
import matplotlib.pyplot as plt
import numpy as np
def f(m, b):
plt.figure(2)
x = np.linspace(-10, 10, num=1000)
plt.plot(x, m * x + b)
plt.ylim(-5, 5)
plt.show()
interactive_plot = interactive(f, m=(-2.0, 2.0), b=(-3, 3, 0.5))
output = interactive_plot.children[-1]
output.layout.height = '350px'
interactive_plot
... should produce this output:
But I'm only getting this:
To be precise, the sliders do pop up for half a second, but seem to be overwritten by the graph. I'm guessing that this is exactly the problem they are adressing. So I thought I could remedy the problem using different values than 350
in output.layout.height = '350px'
, but with absolutley no success so far. I've tried 100, 200, 250, 300, 750 and 1400.
So could there be something else causing the problems?
Thank you for any suggestions!