1
$\begingroup$

Original Function:

f[x_] := E^-2 x Cos[Pi x]

Manipulated Function:

Manipulate[Plot[E^-2 x Cos[Pi x] + c, {x, -3, 4}], {c, 0, 3}]

Is there a way to make these functions appear on the same window side-by-side? Have been trying various codes and commands, but nothing appears to work. I did get close one time, but I couldn't get a slider to appear.

$\endgroup$
2
$\begingroup$
f[x_] := E^-2 x Cos[Pi x] 
colors = ColorData[97, "ColorList"];
Manipulate[Row[Plot[#, {x, -3, 4}, PlotStyle -> #2, ImageSize -> 300, 
  PlotLegends -> Placed[LineLegend[{HoldForm@#}] , Above]] & @@@
   {{f[x], colors[[1]]}, {f[x] + c, colors[[2]]}}, Spacer[10]], {c, 0, 3}] 

enter image description here

Add the option PlotRange -> {-1, 4} to have a fixed vertical range on the second plot:

enter image description here

$\endgroup$
1
$\begingroup$

I suggest that plotting both functions on the same plot rather than side-by-side makes a better looking presentation.

f[x_] := E^-2 x Cos[Pi x]
g[f_, c_, rgb_?ColorQ] := Plot[f[x] + c, {x, -3, 4}, PlotStyle -> rgb]
Manipulate[
  Show[g[f, c, Black], g[f, 0, Red],
    PlotRange -> {-1.2, 3.3},
    AxesOrigin -> {0, 0}],
  {{c, 1}, -1, 3, Appearance -> "Labeled"}]

demo

$\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.