Custom scales for sliders
See original GitHub issueOften when using sliders to manipulate some algorithm parameters it is useful to have logarithmic scale, instead of linear. Now I guess the only way is to manually apply the transformation in the handler, e.g. have the slider from -3 to 3 and in handler write value = 10**value
. One thing is that it’s not really convenient (code defining the real slider range becomes split into two parts in entirely different places), and another is that the slider label of course shows the “raw” value, not the real one used in computations.
I think there is a relatively easy solution - add two function arguments for FloatSlider
to convert back and forth between the slider raw value and the real one (in my example they would be lambda x: 10**x
and lambda x: log10(x)
, and/or maybe a boolean argument log
for convenience, as probably logarithmic scale is needed way more often than other custom ones.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Bump on this issue. Setting a slider to be log-scaled over its range is a common need - I guess it should be as common as a log scale on a plot.
It’s much cleaner having a log setting on the slider than transforming the return values with a separate function. Say you have 30 sliders for otherwise indistinguishable variables that are built programatically and displayed in order - but some need log scaling and others do not. Setting a ‘log’ flag on slider creation would make this really easy, while coding it manually, not so much. Lambdas might be overkill, as log and linear modes will cover 99.9% of use. Log should also be simple to implement.
I will give this a shot