How can I create a dynamic, interactive graph in Mathematica with buttons and sliders for changing the equation type and variables?
-
$\begingroup$ You can do it by reading documentation, which is excellent. $\endgroup$– Victor K.Jan 31 at 6:57
-
$\begingroup$ have you seen Manipulate? There are over 12,000 examples at demonstrations.wolfram.com $\endgroup$– NasserJan 31 at 9:43
-
$\begingroup$ I forgot my manners. A proper welcome with some useful links hopefully $\endgroup$– bmfJan 31 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$– bmfJan 31 at 10:48
1 Answer
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]
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]