How can I get Manipulator control elements to appear on one line?

10

2

By default Manipulator produced by Manipulate with Appearance -> "Open" option have two rows: on the first row the slider is placed, on the second other controls:

Manipulate[
 Row[{Plot[Sin[x (1 + a x)], {x, 0, 6}], 
      Plot[Evaluate@D[Sin[x (1 + a x)], x], {x, 0, 6}]
     }, BaseStyle -> ImageSizeMultipliers -> 2/3], 
 {a, 0, 2, Appearance -> "Open"}]

screenshot

How can I get all the controls placed on one row?

Alexey Popkov

Posted 2013-11-19T14:47:45.630

Reputation: 50 220

1Don't know of an option to Manipulator. Perhaps place them individually? (E.g. Row[{Slider[Dynamic[foo]], InputField[Dynamic[foo], FieldSize -> Tiny], Animator[Dynamic[foo], AnimationRunning -> False, AppearanceElements -> {"StepLeftButton", "StepRightButton", "PlayPauseButton", "FasterSlowerButtons", "DirectionButton"}]}, Spacer[1]] – Michael E2 – 2013-11-19T17:14:55.217

there is no option build-in for this. You try @MichaelE2 method above, that would be the best solution. May be suggestion should be send to support@wolfram.com for this. I wanted to do this once and found no direct way. – Nasser – 2013-11-21T04:46:45.553

Answers

6

Following suggestions in the comments, here is a way to achieve what I want:

Manipulate[
 Row[{
   Plot[Sin[x (1 + a x)], {x, 0, 6}],
   Plot[Evaluate@D[Sin[x (1 + a x)], x], {x, 0, 6}]},
               BaseStyle -> ImageSizeMultipliers -> 2/3],
 {a, 0, 2,
  Grid[{{
         Slider[##, Appearance -> Tiny], 
         InputField[#, FieldSize -> Tiny], 
         Animator[##, AnimationRunning -> False, 
          AppearanceElements -> {"StepLeftButton", "StepRightButton", 
           "PlayPauseButton", "FasterSlowerButtons", "DirectionButton"}]
       }},
          Alignment -> {Center, Center}] &}]

screenshot

Alexey Popkov

Posted 2013-11-19T14:47:45.630

Reputation: 50 220

You probably want Slider[##, Appearance -> Tiny] -- Manipulate passes the domain as a second argument, (0, 2} in your example. – Michael E2 – 2013-11-21T12:27:23.093

@Michael Thanks, I have corrected my answer. But it does not solve the problem with InputField positioning. – Alexey Popkov – 2013-11-21T13:33:52.047

1Do you mean vertical alignment? Try Grid[{{..}}, Alignment -> {Center, Center}] &. Also set InputField[#, ImageSize -> {60, 15}] to get a better match. Cribbed from SystemFiles/FrontEnd/TextResources/MiscExpressions.tr (look for "Manipulator04"). – Michael E2 – 2013-11-21T18:05:59.633

@Michael Thanks, I think the problem is solved (a bit strange that it was so hard, btw). If you wish you can post it as an answer and I'll accept it and delete mine. Or I just leave everything as is. – Alexey Popkov – 2013-11-22T00:21:44.333

Oh, I have enough rep and not enough time, so let's leave it as it is. Thanks, anyway! :) – Michael E2 – 2013-11-22T00:35:14.983

Is there a way to make the controls for several, unrelated variables appear on the same line? – Aron – 2014-04-02T00:54:06.830

@Aron Yes, just include the controls in the Grid[{{...}}]. – Alexey Popkov – 2014-04-02T05:31:53.853

3

Have a look, if this will be better:

    Manipulate[
 Row[{Plot[Sin[x (1 + a x)], {x, 0, 6}], 
   Plot[Evaluate@D[Sin[x (1 + a x)], x], {x, 0, 6}]}, 
  BaseStyle -> ImageSizeMultipliers -> 2/3], {a, 0, 2, 
  Row[{Slider[#, ImageSize -> {200, 20}], 
     InputField[#, ImageSize -> {50, 17}], 
     Animator[#, AnimationRunning -> False, 
      AppearanceElements -> {"StepLeftButton", "StepRightButton", 
        "PlayPauseButton", "FasterSlowerButtons", 
        "DirectionButton"}]}, Spacer[1], 
    BaselinePosition -> Center] &}]

enter image description here

Alexei Boulbitch

Posted 2013-11-19T14:47:45.630

Reputation: 30 405

Unfortunately your code produces worse output in Mathematica 8.0.4 under Windows 7 x64 than the code in my answer. – Alexey Popkov – 2013-11-21T13:31:13.317

@AlexeyPopkov are your names different or what is the reason of i and y at the and? :) – Kuba – 2013-11-21T13:50:33.333

@Kuba The names are of the same origin. The way they are written reflects the madness of the Russian Foreign Office inventing, re-inventing and re-re-inventing rules of how to write our names as well as a personal luck. I suggest you distinguish us by the family names. – Alexei Boulbitch – 2013-11-22T09:02:21.057