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 with self.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 class NormSlider
that additionally takes in a keyword argument norm: mpl.colors.Normalize
to deal with the this. Then it is a matter of calling norm(val)
and norm.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 a SequenceSlider
which would take an argument vals: Sequence
instead of valmin
, valmax
and valstep
. 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.