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
$\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}]]
|improve this answer|||||
$\endgroup$
  • $\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$ – Majis May 25 '17 at 9:58
  • $\begingroup$ I made one more change and it looks better. You can now separate them as much as you want $\endgroup$ – J42161217 May 25 '17 at 10:00
  • 1
    $\begingroup$ just add spaces at " " $\endgroup$ – J42161217 May 25 '17 at 10:01
  • $\begingroup$ Or use the function Spacer $\endgroup$ – Bob Hanlon May 25 '17 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 *)
]
|improve this answer|||||
$\endgroup$
  • $\begingroup$ I see that you edit my code and not OP's... $\endgroup$ – J42161217 May 25 '17 at 15:12
  • $\begingroup$ 30 is a good size. I agree. $\endgroup$ – Gustavo Delfino May 25 '17 at 15:20
  • 2
    $\begingroup$ Yes, changing "Small" to "30" was the key! Spacer wouldn't work otherwise. $\endgroup$ – J42161217 May 25 '17 at 16:07

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.