Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I made the button below for launching an Animate, but it doesn't work at all! Why?

Button["Plot", Animate[Plot[k x, {x, 0, 3}], {k, -2, 2}]]

Thanks in advance.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I found the following to give the result that I think you are looking for. I believe that Animate needs a window to run in.

Button["Plot", MessageDialog[Animate[Plot[k x, {x, 0, 3},
 PlotRange -> {{0, 3}, {-8,8}}], {k, -2, 2}]], Method -> "Queued"]

The Method->"Queued" has been discuss in many other threads.

share|improve this answer
Button["Plot",Animate[Plot[k x,{x,0,3},PlotRange->{{0,3},{-8,8}}],{k,-2,2}]//CreatePalette]

Reference. Also, updated on PlotRange based on @JohnMcGee's answer.

Mathematica graphics

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.