ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 20 Oct 2016 12:38:44 -0500How to fix interact flickering of a ranged plot?http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/ I have this code
var('k');f(x) = sum(1/k,k,1,floor(x))
@interact
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.Thu, 20 Oct 2016 02:05:15 -0500http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/Comment by kcrisman for <p>I have this code</p>
<pre><code>var('k');f(x) = sum(1/k,k,1,floor(x))
@interact
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)
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/?comment=35204#post-id-35204But 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.Thu, 20 Oct 2016 12:38:44 -0500http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/?comment=35204#post-id-35204Comment by Masacroso for <p>I have this code</p>
<pre><code>var('k');f(x) = sum(1/k,k,1,floor(x))
@interact
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)
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/?comment=35203#post-id-35203@kcrisman the compilation is not the problem, we have by example geogebra that dont compile it code but the interactive plots are smooth.Thu, 20 Oct 2016 09:06:02 -0500http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/?comment=35203#post-id-35203Comment by kcrisman for <p>I have this code</p>
<pre><code>var('k');f(x) = sum(1/k,k,1,floor(x))
@interact
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)
</code></pre>
<p>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.</p>
http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/?comment=35202#post-id-35202I'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.Thu, 20 Oct 2016 08:56:09 -0500http://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/?comment=35202#post-id-35202