Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

SageMathCloud Clickable Interact Doesn't Work

I'm trying to run the sample clickable interact given by William Stein at http://permalink.gmane.org/gmane.comp.mathematics.sage.cloud/750, but nothing happens when I click on the image. The code is

@interact
def f0(fun=x*sin(x), mousemove='', click=''):
    g = plot(fun, (0,5))

    def h(p):
        f0.mousemove = p

    def c(p):
        print "click"
        f0.click = p

    show(g, events={'click':c, 'mousemove':h}, gridlines=True, fig_tight=False)

Also, what is p in this code? Is there any documentation on clickable interacts in SMC?

SageMathCloud Clickable Interact Doesn't Work

I'm trying to run the sample clickable interact given by William Stein at http://permalink.gmane.org/gmane.comp.mathematics.sage.cloud/750, but nothing happens when I click on the image. The code is

@interact
def f0(fun=x*sin(x), f0(fun=x*sin(x^2), mousemove='', click=''):
click='(0,0)'):
    click = sage_eval(click)
    g = plot(fun, (0,5))

(x,0,5), zorder=0) + point(click, color='red', pointsize=100, zorder=10)
    ymax = g.ymax(); ymin = g.ymin()
    m = fun.derivative(x)(x=click[0])
    b =  fun(x=click[0]) - m*click[0]
    g += plot(m*x + b, (click[0]-1,click[0]+1), color='red', zorder=10)
    def h(p):
        f0.mousemove = p
     def c(p):
        print "click"
        f0.click = p

f0(click=p)
    show(g, events={'click':c, 'mousemove':h}, gridlines=True, fig_tight=False)
svg=True, gridlines='major', ymin=ymin, ymax=ymax)

Also, what is p in this code? Is there any documentation on clickable interacts in SMC?

click to hide/show revision 3
retagged

SageMathCloud Clickable Interact Doesn't Work

I'm trying to run the sample clickable interact given by William Stein at http://permalink.gmane.org/gmane.comp.mathematics.sage.cloud/750, but nothing happens when I click on the image. The code is

@interact
def f0(fun=x*sin(x^2), mousemove='', click='(0,0)'):
    click = sage_eval(click)
    g = plot(fun, (x,0,5), zorder=0) + point(click, color='red', pointsize=100, zorder=10)
    ymax = g.ymax(); ymin = g.ymin()
    m = fun.derivative(x)(x=click[0])
    b =  fun(x=click[0]) - m*click[0]
    g += plot(m*x + b, (click[0]-1,click[0]+1), color='red', zorder=10)
    def h(p):
        f0.mousemove = p
    def c(p):
        f0(click=p)
    show(g, events={'click':c, 'mousemove':h}, svg=True, gridlines='major', ymin=ymin, ymax=ymax)

Also, what is p in this code? Is there any documentation on clickable interacts in SMC?