-
Notifications
You must be signed in to change notification settings - Fork 947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom scales for sliders #719
Comments
Or one could use d3 scales for this. |
@SylvainCorlay do you mean it can be done using the current version of |
No it cannot be done with the current version. I was merely suggesting that instead of re-inventing the wheel we use d3 scales if we were to implemented scaled sliders. |
I don't think using a Python lambda would make sense here because the scale would be rendered in Javascript. We'd have to serialize the values before sending them to JS land, which would be prone to overflows. |
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. |
Agreed that log should be easy to implement. I think it may be easiest to just implement a FloatLogSlider. I'll make this a 'good first issue' since it seems to be relatively self-contained. |
I will give this a shot |
a slider that uses a logarithmic scale. Closes jupyter-widgets#719
a slider that uses a logarithmic scale. Closes jupyter-widgets#719
a slider that uses a logarithmic scale. Closes jupyter-widgets#719
a slider that uses a logarithmic scale. Closes jupyter-widgets#719
a slider that uses a logarithmic scale. Closes jupyter-widgets#719
a slider that uses a logarithmic scale. Closes jupyter-widgets#719
Often 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 belambda x: 10**x
andlambda x: log10(x)
, and/or maybe a boolean argumentlog
for convenience, as probably logarithmic scale is needed way more often than other custom ones.The text was updated successfully, but these errors were encountered: