2
$\begingroup$

This code:

f[x_, a_, b_] := a x - b x^3
Manipulate[{Plot[f[x, a, b], {x, -2, 2}], 
  n = -\[Integral]f[x, a, b] \[DifferentialD]x;
  Plot[n, {x, -2, 2}, PlotRange -> Automatic]},
       {{a, 1/2, "control parameter"}, -1, 2, 0.1},
       {{b, 1/4, "control parameter 2"}, -1, 2, 0.01}]

Produces this: (if one starts automatic play)

enter image description here

But this looks unprofessional because of annoying up-down movements.

What can be done to stop shaking?

$\endgroup$
  • $\begingroup$ Instead of Automatic, you must set an explicit PlotRange. $\endgroup$ – J. M.'s discontentment Jun 9 '15 at 10:18
  • $\begingroup$ @Guesswhoitis. But what if I want to keep variable plot range? $\endgroup$ – VividD Jun 9 '15 at 10:20
  • $\begingroup$ You'll have to provide for a way to vary the PlotRange somewhere in your Manipulate[]. $\endgroup$ – J. M.'s discontentment Jun 9 '15 at 10:27
8
$\begingroup$

use ImagePadding as in

f[x_, a_, b_] := a x - b x^3
Manipulate[
 {
  Plot[f[x, a, b], {x, -2, 2}, ImagePadding -> 5],
  n = -Integrate[f[x, a, b] , x];
  Plot[n, {x, -2, 2}, PlotRange -> Automatic, ImagePadding -> 5]
  },
 {{a, 1/2, "control parameter"}, -1, 2, 0.1},
 {{b, 1/4, "control parameter 2"}, -1, 2, 0.01}
 ]

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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