Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.