Sharedsupport / 2017-01-07-clickable-interacts.sagewsOpen in CoCalc
Authors: ℏal Snyder, William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.

See https://github.com/sagemathinc/smc/issues/1459

@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)
Interact: please open in CoCalc