3
$\begingroup$

Consider the following code:

Row[
 Table[
  With[{i = i},
   x = ConstantArray[0.5, 3];
   Column[{i, 
     VerticalSlider[Dynamic@x[[i]], Appearance -> "Labeled", 
      ImageSize -> Small]}, Alignment -> Center]
   ],
  {i, 1, 3, 1}
  ]
 ]

It creates 3 vertical sliders which are widely spaced apart. How can I reduce the spacing between them?

One more thing, I wish to interchange the positions of the slider indices and their values.

$\endgroup$

2 Answers 2

2
$\begingroup$

try this

Row[Table[With[{i = i}, x = ConstantArray[0.5, 3];
Column[{i, 
 VerticalSlider[x[[i]], Appearance -> "Labeled", ImageSize -> 30],
  "      "}, Alignment -> Center]], {i, 1, 3, 1}]]

you can manipulate spacing by adding spaces at " "


here are slider indices and their values placed at the bottom

Row[Table[With[{i = i}, x = ConstantArray[0.5, 3];
Column[{VerticalSlider[Dynamic@x[[i]], Appearance -> "Labeled", 
  ImageSize -> 30], "      ", i}, Alignment -> Center]], {i, 1, 3,
1}]]
$\endgroup$
4
  • $\begingroup$ Thanks for your answer. One observation: if you try to reduce the height, it creates a big gap between the sliders and their corresponding values. $\endgroup$
    – user36426
    Commented May 25, 2017 at 9:58
  • $\begingroup$ I made one more change and it looks better. You can now separate them as much as you want $\endgroup$
    – ZaMoC
    Commented May 25, 2017 at 10:00
  • 1
    $\begingroup$ just add spaces at " " $\endgroup$
    – ZaMoC
    Commented May 25, 2017 at 10:01
  • $\begingroup$ Or use the function Spacer $\endgroup$
    – Bob Hanlon
    Commented May 25, 2017 at 19:08
1
$\begingroup$

This also works:

Row[
  Table[With[{i = i}, x = ConstantArray[0.5, 3];
    Column[{i, 
            VerticalSlider[Dynamic@x[[i]], 
                           Appearance -> "Labeled", 
                           ImageSize -> 30]},
            Alignment -> Center]
    ],
    {i, 1, 3, 1}], 
  Spacer[10] (* Row second parameter is a separator between successive elements *)
]
$\endgroup$
3
  • $\begingroup$ I see that you edit my code and not OP's... $\endgroup$
    – ZaMoC
    Commented May 25, 2017 at 15:12
  • $\begingroup$ 30 is a good size. I agree. $\endgroup$ Commented May 25, 2017 at 15:20
  • 2
    $\begingroup$ Yes, changing "Small" to "30" was the key! Spacer wouldn't work otherwise. $\endgroup$
    – ZaMoC
    Commented May 25, 2017 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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