Ask Your Question
1

Are there options for interactive/dynamic content?

asked 12 years ago

ooglyboogly gravatar image

updated 12 years ago

I'm starting to switch over to sage from mathematica, and so far the biggest thing I'm missing is the ability to make interactive applets. I managed to get mplh5canvas up and running. While it's a nice start, It's far from the sort of thing I can do with mathematica.

In mathematica, one can make an interactive sin graph with something like (I forget if the dynamic tag goes with the a or the plot[]):

Slider[Dynamic[a],{0,5}]
Plot[Dynamic[a]*sin[x],{x,-10,10}]

And of course it's even easier with Manipulate[].

How far is Sage from this sort of functionality? I think this sort of thing is immensely helpful to students who just want to explore a function.

If I learn how to effectively use the HTML 5 canvas and javascript, are dynamic plots within reach?

EDIT: Thanks a lot! Interact seems to be what I was looking for.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
3

answered 12 years ago

Eviatar Bach gravatar image

updated 12 years ago

Yes, there is a way to do this, with interact.

For your example, the equivalent in Sage would be (this goes in a notebook cell):

@interact
def interact_sin(a=slider(0, 5)):
    plot(a * sin(x), -10, 10).show()
Preview: (hide)
link

Comments

1

plot(a * sin(x), -10, 10,ymin=-5,ymax=5).show() looks better.

Shashank gravatar imageShashank ( 12 years ago )

Yeah, but I wanted to make it the same as the poster's example.

Eviatar Bach gravatar imageEviatar Bach ( 12 years ago )

Yes I understand. My comment was for the OP.

Shashank gravatar imageShashank ( 12 years ago )
1

answered 12 years ago

Shashank gravatar image

There are a few examples on the sagemath.org website. Have a look at the following links

http://wiki.sagemath.org/interact/cal...

http://wiki.sagemath.org/interact/alg...

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 1,196 times

Last updated: May 30 '12