-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Milestone
Description
Problem
Currently, if you want to use widgets to set two related values (e.g. vmin
and vmax
for thresholding an image) you need to create two sliders. This makes it difficult to maintain the same experience between ipywidgets and matplotlib widgets. In particular I would like to be able to use this thresholding setup with both ipywidgets and matplotlib widgets
%matplotlib ipympl
import matplotlib.pyplot as plt
import ipywidgets as widgets
img = plt.imread("https://matplotlib.org/3.3.1/_images/stinkbug.png")
fig, ax = plt.subplots()
im = ax.imshow(img)
slider = widgets.FloatRangeSlider(value=(0.,1.), min=0, max=1., step=.001)
def update(change):
im.norm.vmin = slider.value[0]
im.norm.vmax = slider.value[1]
fig.canvas.draw()
slider.observe(update, names='value')
display(slider)
Proposed Solution
Create a RangeSlider
class in widgets.py
that give analogous behavior to the ipywidgets version: https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20List.html#FloatRangeSlider