Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[ENH]: More generic slider #26395

Copy link
Copy link
Open
Open
Copy link
@VRehnberg

Description

@VRehnberg
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.