Is there a way to modify the plot inside IPython "interact" function rather than replotting it?
In case when the plot contains a lot of heavy graphics (or some parts require heavy calculations) it would be much faster than doing the plot from the scratch.
I'm trying the following code, but it does not work: after changing the slider the whole plot becomes blank.
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.html.widgets import interact
import numpy as np
x = np.arange(0,11.)
y1 = x / 10.
y2 = np.random.rand(len(x))
plt.plot(x,y1)
plt.plot(x,y2)
plt.ylim([0,1])
ax = plt.gca()
def replot_it(a):
ax.lines.pop(1)
y = (x/10.)**a
ax.plot(x,y)
interact(replot_it, a=(0.,5.))
I would appreciate any suggestions.