-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Added a new public API update_range to Slider widget. It helps to change the valmin and valmax of the Slider #20579
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
Draft
BSNayal
wants to merge
16
commits into
matplotlib:main
Choose a base branch
from
BSNayal:slider_dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
db6f293
Added a public API "update_range" to Slider widget
BSNayal 642b247
Merge branch 'matplotlib:master' into slider_dev
BSNayal f4b25d8
Solved issues shown by flakes
BSNayal c0bcb22
Added a public API "update_range" to Slider widget
BSNayal f024dff
Solved issues shown by flakes
BSNayal ac4d092
Merge branch 'slider_dev' of https://github.com/BSNayal/matplotlib in…
BSNayal 157f8bb
Merge branch 'matplotlib:master' into slider_dev
BSNayal 3294fc9
Merge branch 'slider_dev' of https://github.com/BSNayal/matplotlib in…
BSNayal ad59d5a
Worked on the given code review comments
BSNayal fcfa937
Worked on the review comments:
BSNayal 80cadb1
Added a public API "update_range" to Slider widget
BSNayal 24732ba
Solved issues shown by flakes
BSNayal a030ebc
Worked on the given code review comments
BSNayal df26a4c
Worked on the review comments:
BSNayal 06acf85
Merge branch 'slider_dev' of
BSNayal c2f2a23
Merge branch 'matplotlib:master' into slider_dev
BSNayal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,6 +306,19 @@ def reset(self): | |
if self.val != self.valinit: | ||
self.set_val(self.valinit) | ||
|
||
def set_limits(self, vmin=None, vmax=None): | ||
"""Update the limits of the slider.""" | ||
if vmin is None and vmax is None: | ||
return | ||
if vmin is not None: | ||
self.valmin = vmin | ||
if vmax is not None: | ||
self.valmax = vmax | ||
if self.orientation == 'vertical': | ||
self.ax.set_ylim((self.valmin, self.valmax)) | ||
else: | ||
self.ax.set_xlim((self.valmin, self.valmax)) | ||
|
||
|
||
class Slider(SliderBase): | ||
""" | ||
|
@@ -583,6 +596,18 @@ def on_changed(self, func): | |
""" | ||
return self._observers.connect('changed', lambda val: func(val)) | ||
|
||
def set_limits(self, vmin=None, vmax=None): | ||
QuLogic marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above about argument names. |
||
"""Update the limits of the slider.""" | ||
super().set_limits(vmin=vmin, vmax=vmax) | ||
self.val = self._value_in_bounds(self.val) | ||
# if we reset the slider after updating the limits then we should have | ||
# the proper valinit value | ||
self.valinit = self._value_in_bounds(self.valinit) | ||
if self.orientation == 'vertical': | ||
self.hline.set_ydata(self.valinit) | ||
else: | ||
self.vline.set_xdata(self.valinit) | ||
|
||
|
||
class RangeSlider(SliderBase): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does |
||
""" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To match
__init__
, these should probably be named: