Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Problem
I've found the current implementation of slider to be quite limited in what you can do. Quite often I don't want a scaler with a linear behaviour but rather with log scale or something even more exotic.
My typical work around is to have vmin and vmax transformed to a linear scale and then call the inverse of this transform in the update function that uses the values from my sliders and sets a new custom text withself.valtxt.set_text
.
However, having to this kind of transform inverse combination for each slider and usage of slider is rather anoying and can easily lead to mistakes.
Some other people with similar use cases:
Proposed solution
I imagine that you could create a classNormSlider
that additionally takes in a keyword argumentnorm: mpl.colors.Normalize
to deal with the this. Then it is a matter of callingnorm(val)
andnorm.inverse(scale_val)
inside this class instead of having to keep track of it outside the Slider class.
It would still be limited to monotonic transformations as far as I can tell, but it is atleast as general as using
norm = mpl.colors.FuncNorm((_forward, _inverse), vmin=vmin, vmax=vmax)
Other solutions I can think of would be to have aSequenceSlider
which would take an argumentvals: Sequence
instead ofvalmin
,valmax
andvalstep
. Then the slider would be indexing the values in this array instead. This is arguably as general as you can get.
I'm not sure which one would be better.