Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It still has to create the actual image each time. The graphics object is cached, but the actual image isn't. Also, if you are running from a web notebook, it also takes time to transfer the image to your browser. My guess is that the transfer time is taking most of that half second. Have you tried running that code locally on your own computer?

In the code below, I actually write all of the images out first and the interact just retrieves the right image. There is still a bit of lag, but it is a bit faster for me.

n=100
for i in range(n+1):
    f(x)=sin(N(i/10)*x)
    plot(f,plot_points=10000).save(DATA+'image%d.png'%i)

@interact
def _(a=(0..n)):
    html('<img src="data/image%d.png"/>'%a)