On Wed, May 3, 2017 at 8:31 AM, Alexander Ulyanov
<[email protected]> wrote:
> Hi!
>
> Last week I got curious to figure out if I could control a Sage cell using
> mouse events. I'm quite a novice in Sage and also have no experience with
> Javascript. Here is the actual example I was looking at then. Surely it is
> tempting to be able to just click in the plot to choose a point instead of
> using the sliders for its coordinates.
>
> Then I found this post and tried the code from there:
>
> @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)
>
> Prof. Stein ran this fine in Sage cloud. However, the result I now get in
> Sage cell is:

I didn't just run this fine in SageMathCloud.  I spent a few days and
reimplementing the entire @interact frontend and backend from scratch
for SageMathCloud, and while I was at it added click support.   It's a
different implementation than the one in Sage Cell.  It's also
slightly broken right now:
https://github.com/sagemathinc/smc/issues/1459

>
> TypeError: matplotlib() got an unexpected keyword argument 'svg'
>
>
> The page outside the cell was identical to my example above. Commenting out
> the svg argument, I get
>
> TypeError: matplotlib() got an unexpected keyword argument 'events'
>
> At this point I'm stuck and looking for help.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/e74ede45-c83d-498f-8ee1-44fe97492942%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
William (http://wstein.org)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-cell" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-cell/CACLE5GA4%2B7KjL9n7uZQRg89cvBbnqD8Nt%3Dnyk2enEOed9C_67w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to