Open
Description
I encounter a bug in VSCode notebook when using a FigureWidget
for a go.Image
trace using source
string instead of z
attribute (px.imshow
optimization).
The bug is: once you hover the image with mouse the kernel is unresponsive, i.e. you can't run any cell anymore.
The bug is not present when running the notebook through Jupyter web interface.
Reproducible example
import numpy as np
import plotly.express as px
import plotly.graph_objects as go
from plotly.utils import image_array_to_data_uri
img = (np.random.rand(10, 10, 3) * 255).astype(np.uint8)
img_str = image_array_to_data_uri(img)
# --- Using normal go.Figure is OK
# px.imshow(img) # OK
# go.Figure(go.Image(z=img)) # OK
# go.Figure(go.Image(source=img_str)) # OK
# --- Using go.FigureWidget and Image.z is OK
# go.FigureWidget(go.Image(z=img)) # OK
# --- Using go.FigureWidget and Image.source is NOT OK
# go.FigureWidget(px.imshow(img)) # NOK
go.FigureWidget(go.Image(source=img_str)) # NOK
Versions
$ conda list | grep -E 'plotly|ipykernel|pillow|numpy|pandas'
ipykernel 6.26.0 pyhf8b6a83_0 conda-forge
numpy 1.26.0 py312heda63a1_0 conda-forge
pandas 2.1.3 py312hfb8ada1_0 conda-forge
pillow 10.1.0 py312hf3581a9_0 conda-forge
plotly 5.18.0 pyhd8ed1ab_0 conda-forge
$ code --version
1.84.2
1a5daa3a0231a0fbba4f14db7ec463cf99d7768e
x64