5
$\begingroup$

NB: I've seen other post's that ask similar questions, but I haven't found one whose answers address the problems described here.


The code below is a very artificial example that illustrates the problem.

Manipulate[
 Plot[Cos[k x], {x, 0, 2 Pi}],
 {{k, 0}, -0.00001, 0.00001, Appearance -> "Labeled"}
 , ContentSize -> {300, 200}
 , ControlPlacement -> Left
]

As one moves the slider, the widget's appearance becomes completely unstable: the widget's overall dimensions fluctuate, the relative positioning of its contents also fluctuates, scrollbars pop in and out of existence, etc.

How can this thing be stabilized?


Some important notes:

  • I have expressly placed the controls to the left to bring out the problem with the fluctuating label width. Please take the left-placement of the controls as a given.

  • It's fine with me if the number of digits of precision shown changes as the slider is displaced, as long as this does not result in a horizontal shifting of the plot area. IOW, there should be enough extra space for as many digits of precision may appear.

  • I saw no difference with either PreserveImageOptions->True or PreserveImageOptions->False.

$\endgroup$
  • 1
    $\begingroup$ I think you'll have to be very explicit about controls, e.g. try Labeled[Control[{k, -0.0001, 0.0001}], Pane[Dynamic@k, ImageSize -> 50,ImageSizeAction -> "ShrinkToFit"], Right] in place of {{k,0}....} $\endgroup$ – N.J.Evans Feb 7 '17 at 20:18
  • $\begingroup$ Not quite what you seek, but this helps: Appearance -> "Open". $\endgroup$ – David G. Stork Feb 7 '17 at 20:22
3
$\begingroup$

This is an alternative:

Manipulate[
    Plot[Cos[k x], {x, 0, 2 Pi}], 
    Row[{"k  ",
         Manipulator[Dynamic[k], {-0.00001, 0.00001}],
         Spacer[10],
         Pane[Dynamic[k], 100]}],
    ContentSize -> {300, 200}, 
    ControlPlacement -> Left]
$\endgroup$
3
$\begingroup$

Another option is to build the Control by yourself and fix the size.

Manipulate[Plot[Cos[k x], {x, 0, 2 Pi}],
 Control[Row[{"k", Slider[Dynamic[k], {-0.00001, 0.00001}], 
    Dynamic[Pane[k, 80]]}, Spacer[5]]],
 ContentSize -> {300, 200},
 ControlPlacement -> Left]
$\endgroup$
2
$\begingroup$

You can use the undocumented method option "ControlAreaDisplayFunction"

Manipulate[
 Plot[Cos[k x], {x, 0, 2 Pi}],
 {{k, 0}, -0.00001, 0.00001, Appearance -> "Labeled"}
 , ContentSize -> {300, 200}
 , ControlPlacement -> Left
 , Method -> "ControlAreaDisplayFunction" -> (Pane[#1, 300] &)]
$\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.