1
$\begingroup$

The example below is just a simple toy for the sake of this question.

The widget shown below uses a slider to set the horizontal location of a vertical line:

Module[
 {X},
 Manipulate[
  Module[{x = X},
   Show[
    Graphics[Line[{{x, 0}, {x, 20}}]],
    PlotRange -> {{0, 100}, {0, 20}},
    Frame -> True,
    AspectRatio -> Automatic
    ]
   ],
  {{X, 50}, 0, 100, 1, LabeledSlider}
  ]
]

Mathematica graphics

Note that, as one moves the slider, its current value is displayed at the right of it.

Suppose, however, that one wanted to display the log10 of this value instead.

One could do this

Module[
 {log10x},
 Manipulate[
  Module[{x = 10^log10x},
   Show[
    Graphics[Line[{{x, 0}, {x, 20}}]],
    PlotRange -> {{0, 100}, {0, 20}},
    Frame -> True,
    AspectRatio -> Automatic
    ]
   ],
  {{log10x, N@Log10[50]}, -2, 2, 0.1, LabeledSlider}
  ]
]

Mathematica graphics

In this version, the log10 of the value is displayed, but the relationship between the slider's movement and the position of the vertical line is no longer uniform throughout the slider's range: the vertical line accelerates (relative to the slider) as the slider approaches its rightmost limit 1.

Questions:

  1. How can I retain the first version's uniform relationship between the slider's motion and the position of the vertical line, but show the log10 of the value next to the slider?

  2. How can I control the string to the left of the slider? (to display, for example, Log10 of x, instead of log10x$4159?)


NB: I have not been able to find any documentation at all for LabeledSlider.


1Alternatively, the position of the slider relative to its endpoints does not correspond to the position of the vertical line relative to the plot's horizontal range. For example, in the second figure shown, the slider is close to its rightmost end, while the vertical line is midway along its range.

$\endgroup$
1
$\begingroup$

How about:

Manipulate[
    Show[
        Graphics[Line[{{x,0},{x,20}}]],
        PlotRange->{{0,100},{0,20}},Frame->True,AspectRatio->Automatic
    ],
    Row[{
        Control@{{x, 50., "log10x"}, 0.1, 100, 0.1, AppearanceElements->None},
        Dynamic[Log10[x]]
    }]
]

enter image description here

$\endgroup$
1
$\begingroup$

I do not know how to change the value to the right, but the label to the left should work like this

     Manipulate[
 Module[{x = 10^log10x}, 
  Show[Graphics[Line[{{x, 0}, {x, 20}}]], 
   PlotRange -> {{0, 100}, {0, 20}}, Frame -> True, 
   AspectRatio -> Automatic]], {{log10x, N@Log10[50], 
   "Log10 of X"}, -2, 2, 0.1, Appearance -> "Labeled"}]
$\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.