9
$\begingroup$

I have an example here from the solution of @krasten 7. In this I would like some vertical spacing between the checkboxes. Any ideas?

prjs = {prj1, prj2, prj3} = RandomReal[#, 100] & /@ {1, 2, 3};

Manipulate[ListPlot[prjs[[projectNo]], Joined -> True], 
 {{projectNo, {1}}, Range[Length@prjs], ControlType -> CheckboxBar,Appearance -> 
"Vertical", ControlPlacement -> Right }]

In addition to it, I am also looking for more control options like checkbox size or relative postions. Appreciate your time. Thanks.

enter image description here

$\endgroup$

3 Answers 3

11
$\begingroup$

You can wrap CheckboxBar with Style using the option DefaultOptions to modify the Spacings option of Grid objects:

ClearAll[addVerticalSpace]
addVerticalSpace[vs_: .3] := 
 Style[#, DefaultOptions -> {Grid -> {Spacings -> {Automatic, vs}}}] &

Examples:

cbb = CheckboxBar[{1}, Range[4], Appearance -> "Vertical"];

Row[{cbb, 
  addVerticalSpace[] @ cbb, 
  addVerticalSpace[0] @ cbb, 
  addVerticalSpace[1] @ cbb, 
  addVerticalSpace[2] @ cbb}, 
 Spacer[20]]

enter image description here

prjs = RandomReal[#, 100] & /@ {1, 2, 3};

addVerticalSpace[2] @
 Manipulate[ListPlot[prjs[[projectNo]], Joined -> True], 
 {{projectNo, {1}}, Range[Length@prjs], ControlType -> CheckboxBar, 
   Appearance -> "Vertical", ControlPlacement -> Right}]

enter image description here

$\endgroup$
1
  • $\begingroup$ you are amazing!! $\endgroup$
    – Rupesh
    Mar 19 at 3:52
6
$\begingroup$
prjs = {prj1, prj2, prj3} =
   RandomReal[#, 100] & /@ {1, 2, 3};

To widen the spacing of the checkboxes, you can use multi-row labels with the extra rows empty.

Manipulate[
 ListPlot[prjs[[projectNo]],
  Joined -> True],
 {{projectNo, {1}, "Project\nNumber"},
  (# -> StringForm["``\n\n\n", #]) & /@
   Range[Length@prjs],
  ControlType -> CheckboxBar,
  Appearance -> "Vertical",
  ControlPlacement -> Right}]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks @Bob Hanlon, it's much simpler $\endgroup$
    – Rupesh
    Mar 19 at 3:53
5
$\begingroup$

You can also wrap labels with Pane and use the option ImageSize to control the vertical span of labels:

ClearAll[paneWrap]
paneWrap[vSize_: 20] := Map[# -> Pane[#, Alignment -> Center, 
   BaselinePosition -> Baseline, ImageSize -> {Automatic, vSize}] &]

Examples:

prjs = RandomReal[#, 100] & /@ {1, 2, 3};

Row[{CheckboxBar[{1}, Range[Length @ prjs], Appearance -> "Vertical"],
  CheckboxBar[{1}, paneWrap[] @ Range[Length @ prjs], Appearance -> "Vertical"],
  CheckboxBar[{1}, paneWrap[30] @ Range[Length @ prjs], Appearance -> "Vertical"]}, 
  Spacer[20]]

enter image description here

Manipulate[ListPlot[prjs[[projectNo]], Joined -> True], 
 {{projectNo, {1}}, paneWrap[75] @ Range[Length @ prjs],
   ControlType -> CheckboxBar, Appearance -> "Vertical", ControlPlacement -> Right}]

enter image description here

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