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.

The code below is something I wrote quickly to simulate the problem I'm having with more complex code. I use Row (or Grid) to get the first 2 manipulate variables (a and b) on one line above the plot and I want the other 2 variables (c and d) in one line below the plot. I can get the controls where I want them without Row (or Grid) but then they appear in a column. Whenever I add Row all controls appear to have the same placement. I wasn't able to find any other posts that could help me with this problem.

Manipulate[
 f = a*x^3 + b*x^2 + c*x + d;
 Plot[f, {x, -4, 4}],
 Row[{
   Control[{{a, 1, "a"}, 0, 3, ControlPlacement -> Top}],
   Control[{{b, 2, "b"}, 0, 5, ControlPlacement -> Top}]
   }],
 Row[{
   Control[{{c, 1, "c"}, 0, 4, ControlPlacement -> Bottom}],
   Control[{{d, 0, "d"}, 0, 2, ControlPlacement -> Bottom}]
   }]
 ]

enter image description here

share|improve this question
3  
You can get more flexibility in positioning if you use a DynamicModule and build up the grid and control elements. –  rm -rf Mar 6 at 5:20

2 Answers 2

up vote 5 down vote accepted

That is how you might do it within the framework of Manipulate:

    Manipulate[
 Plot[a*x^3 + b*x^2 + c*x + d, {x, -4, 4}], 
 Row[{Control[{{a, 1, "a"}, 0, 3}], Spacer[20], Control[{{b, 2, "b"}, 0, 5}]}], 
 Row[{Control[{{c, 1, "c"}, 0, 4}], Spacer[20], Control[{{d, 0, "d"}, 0, 2}]}],
 ControlPlacement -> {Top, Top, Bottom, Bottom}
              ]

It looks as follows:enter image description here Have fun.

share|improve this answer
    
Thank you! I don't understand how I didn't even think of this. –  baumannr Mar 7 at 0:37

Illustrating the advice of rm-rf:

DynamicModule[
 {f, a, b, c, d},
 f = a*x^3 + b*x^2 + c*x + d;
 Column[
  {Row[{"a  ", Slider[Dynamic[a], {0, 3}], "b  ", 
     Slider[Dynamic[b], {0, 3}]}, Frame -> True],
   Dynamic@
    Plot[f, {x, -4, 4}, ImageSize -> 400, PlotRange -> {-50, 50}, 
     PlotStyle -> {Red, Thick}, 
     PlotLabel -> 
      Row[{Style["f(x)=", 20], Style[TraditionalForm[f], 20]}]],
   Row[{"c  " Slider[Dynamic[c], {0, 3}], "d  ", 
     Slider[Dynamic[d], {0, 3}]}, Frame -> True]}, Frame -> True
  , Background -> LightYellow]]

I am sorry for not using some parameter ranges, but aim was illustrative:

enter image description here

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.