How to fix interact flickering of a ranged plot?

asked 2016-10-20 02:05:15 -0600

Masacroso gravatar image

I have this code

var('k');f(x) = sum(1/k,k,1,floor(x))
def _(n=slider(20,200,step_size=1)):
    p1 = plot(f(x),(x,1,n),fill=log(x),fillcolor="lightgreen",alpha=0.2,legend_label='$f(x)=\sum_{k=1}^{\lfloor x \\rfloor}\\frac{1}{k}$')
    p2 = plot(log(x),(x,1,n),fill='axis',fillcolor="lightgrey",legend_label="$g(x)=\log (x)$")
    show(p1 + p2)

but this have the problem that when I change the value of the slider the graph flicker instead of a smooth change. It is a way to fix this or change this behavior? Thank you.

edit retag flag offensive close merge delete


I'm not sure what you mean by flicker, but I assume you mean that there is a slight delay in the update. Since Sage is not compiling the interact, but still interacting with the Sage program itself for each computation, this delay is inevitable. There has been some work on making it much less, but I don't know where that has gone lately.

kcrisman gravatar imagekcrisman ( 2016-10-20 08:56:09 -0600 )edit

@kcrisman the compilation is not the problem, we have by example geogebra that dont compile it code but the interactive plots are smooth.

Masacroso gravatar imageMasacroso ( 2016-10-20 09:06:02 -0600 )edit

But Geogebra applets are themselves compiled Java, are they not? And so is (or was) the program itself. Whereas Sage interactive graphics are still images. There are javascript libraries one could incorporate into Sage which could achieve (some) of what you want, but so far no one has made a link from the plotting code directly to these.

kcrisman gravatar imagekcrisman ( 2016-10-20 12:38:44 -0600 )edit