mpl-extensions / mpl-interactions

Sliders to control matplotlib and other interactive goodies. Works in any interactive backend and even uses ipywidgets when in a Jupyter notebook
https://mpl-interactions.rtfd.io
BSD 3-Clause "New" or "Revised" License
132 stars 20 forks source link

sliders not showing with ipywidgets 8.0.1 #255

Closed jubrau closed 2 years ago

jubrau commented 2 years ago

Bug report

Bug summary

After freshly installing using pip install mpl_interactions[jupyter], sliders generated by plot or hyperslice do not appear in the generated figure anymore.

Code for reproduction

conda create -n test python=3.9
conda activate test
pip install mpl_interactions[jupyter]

(installs ipywidgets==8.0.1)

import mpl_interactions.ipyplot as iplt
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, np.pi, 100)
tau = np.linspace(0.5, 10, 100)

def f1(x, tau, beta):
    return np.sin(x * tau) * x * beta
def f2(x, tau, beta):
    return np.sin(x * beta) * x * tau

fig, ax = plt.subplots()
controls = iplt.plot(x, f1, tau=tau, beta=(1, 10, 100), label="f1")
iplt.plot(x, f2, controls=controls, label="f2")
_ = plt.legend()
plt.show()

Example from the documentation. Sliders are not shown in notebook.

Actual outcome

Expected outcome Sliders should appear above the Figure title. Works with ipywidgets 7.6.3.

Version Info

ianhi commented 2 years ago

Hi @jubrau are you sitll having this issue? I can't replicate this with ipywidgets 8.0.2

I know there were some initial issues with th eipywidgets release, so it's possible that 8.0.2 fixed the issue you were having.

jubrau commented 2 years ago

After installing ipywidgets 8.0.2 both in the base conda environment and in the actual environment the bug seems to be gone. Thanks!