1
$\begingroup$

How can I create a dynamic, interactive graph in Mathematica with buttons and sliders for changing the equation type and variables?

$\endgroup$
4
  • $\begingroup$ You can do it by reading documentation, which is excellent. $\endgroup$
    – Victor K.
    Jan 31, 2023 at 6:57
  • $\begingroup$ have you seen Manipulate? There are over 12,000 examples at demonstrations.wolfram.com $\endgroup$
    – Nasser
    Jan 31, 2023 at 9:43
  • $\begingroup$ I forgot my manners. A proper welcome with some useful links hopefully $\endgroup$
    – bmf
    Jan 31, 2023 at 10:48
  • $\begingroup$ Welcome to Mathematica S.E. To start: 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, since the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) consider accepting the answer, if any, that solves your problem, by clicking checkmark sign, 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bmf
    Jan 31, 2023 at 10:48

1 Answer 1

5
$\begingroup$
g = 1;
dm = DynamicModule[{a}, 
   Column[{Dynamic@
      Plot[Sin[(a + g) x], {x, 0, Pi}, PlotRange -> {All, {-1, 1}}], 
     Slider[Dynamic@a, {0, 4}]}]];
Button["g++", g = g + 1]
Dynamic[dm]

Blockquote

Edit: many thanks to @Nasser for the comment. Indeed, Manipulate might be more straightforward. It works like this:

g = 1;
Manipulate[
 Plot[Sin[(a + g) x], {x, 0, 2 Pi}, PlotLabel -> Row[{"a=", a}]], {a, 
  0, 5}]
Button["g++", g = g + 1]
$\endgroup$
2
  • 1
    $\begingroup$ nice example but I find Manipulate much simpler myself. $\endgroup$
    – Nasser
    Jan 31, 2023 at 9:44
  • $\begingroup$ @Nasser thanks for pointing this out. I have adopted your comment in the edit :-) $\endgroup$
    – bmf
    Jan 31, 2023 at 9:55

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