You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I had just created an issue about images failing with the new FigureWidget. However, I've come to realize that the issue is more nuanced (and general) than previously noted and so thought I'd close that issue and open a new one.
An image can be added to an instance of a FigureWidget, but only to the first instance; an image cannot be added to a second. The same goes for heatmaps. Slightly different behavior, though still unexpected, is observed for bars. I suspect this erratic behavior is associated with the adoption of anywidget (PR #4823).
Consider the following examples (run from a classic jupyter notebook in Chrome):
Example 1a: successful addition of image to two FigureWidget instances (expected behavior, pre-anywidget)
plotly v5.24.1
anywidget not installed
notebook v7.3.1
run the cell below twice
importplotly.graph_objectsasgofig=go.FigureWidget()
# Add an image to the figurefig.add_layout_image(
dict(
source="https://raw.githubusercontent.com/cldougl/plot_images/add_r_img/vox.png",
xref="x",
yref="y",
x=1,
y=1,
sizex=1,
sizey=1,
xanchor="center",
yanchor="middle"
)
)
fig.show()
first output:
second output:
Example 1b: unsuccessful addition of image to two FigureWidget instances (unexpected behavior, post-anywidget)
importplotly.graph_objectsasgofig1=go.FigureWidget()
# Add an image to the figurefig1.add_layout_image(
dict(
source="https://raw.githubusercontent.com/cldougl/plot_images/add_r_img/vox.png",
xref="x",
yref="y",
x=1,
y=1,
sizex=1,
sizey=1,
xanchor="center",
yanchor="middle"
)
)
fig1.show()
cell 2
# Create a Plotly figurefig2=go.FigureWidget()
# Add an image to the figurefig2.add_layout_image(
dict(
source="https://images.plot.ly/language-icons/api-home/python-logo.png",
xref="x",
yref="y",
x=1,
y=1,
sizex=1,
sizey=1,
xanchor="center",
yanchor="middle"
)
)
fig2.show()
Example 6a: successful addition of image to second FigureWidget instance regardless of data added to first FigureWidget instance (expected behavior, pre-anywidget)
plotly v5.24.1
anywidget not installed
notebook v7.3.1
importplotly.graph_objectsasgo# Create a Plotly figurefig2=go.FigureWidget()
# Add an image to the figurefig2.add_layout_image(
dict(
source="https://raw.githubusercontent.com/cldougl/plot_images/add_r_img/vox.png",
xref="x",
yref="y",
x=1,
y=1,
sizex=1,
sizey=1,
xanchor="center",
yanchor="middle"
)
)
fig2.show()
Example 6b: unsuccessful addition of image to second FigureWidget instance regardless of data added to first FigureWidget instance (unexpected behavior, post-anywidget)
Thank you for this detailed bug report! I'm looking into this now. I am seeing what you're seeing with rerunning the cells.
One behavior I'm already seeing is that if you restart the kernel before re-running the cell, this bug doesn't occur (still a bug, just noting this for debugging).
Hi @marthacryan, I've observed some new, potentially positive behavior. If I first create an instance of go.Figure and then convert it to a go.FigureWidget , the documented problem does not occur. Strange!
Example:
Run the below in a cell as many times as you'd like 🥳
importplotly.graph_objectsasgo# Create a Plotly figurefig=go.Figure()
# Add an image to the figurefig.add_layout_image(
dict(
source="https://images.plot.ly/language-icons/api-home/python-logo.png",
xref="x",
yref="y",
x=1,
y=1,
sizex=1,
sizey=1,
xanchor="center",
yanchor="middle"
)
)
fig=go.FigureWidget(fig)
fig
Hey Plotly team!
I had just created an issue about images failing with the new
FigureWidget
. However, I've come to realize that the issue is more nuanced (and general) than previously noted and so thought I'd close that issue and open a new one.An image can be added to an instance of a
FigureWidget
, but only to the first instance; an image cannot be added to a second. The same goes for heatmaps. Slightly different behavior, though still unexpected, is observed for bars. I suspect this erratic behavior is associated with the adoption ofanywidget
(PR #4823).Consider the following examples (run from a classic jupyter notebook in Chrome):
Example 1a: successful addition of image to two
FigureWidget
instances (expected behavior, pre-anywidget)plotly v5.24.1
anywidget not installed
notebook v7.3.1
run the cell below twice
first output:
second output:
Example 1b: unsuccessful addition of image to two
FigureWidget
instances (unexpected behavior, post-anywidget)plotly v6.0.0rc0
anywidget v0.9.13
notebook v7.3.1
run the cell below twice
first output:
second output:
Example 2a: successful addition of heatmap to two
FigureWidget
instances (expected behavior, pre-anywidget)plotly v5.24.1
anywidget not installed
notebook v7.3.1
run the cell below twice
first output:
second output:
Example 2b: unsuccessful addition of heatmap to two
FigureWidget
instances (unexpected behavior, post-anywidget)plotly v6.0.0rc0
anywidget v0.9.13
notebook v7.3.1
run the cell below twice
first output:
second output:
Example 3a: successful addition of bars to two
FigureWidget
instances (expected behavior, pre-anywidget)plotly v5.24.1
anywidget not installed
notebook v7.3.1
run the cell below twice
first output
second output
Example 3b: discrepancy in addition of bars to two
FigureWidget
instances (uexpected behavior, post-anywidget)plotly v6.0.0rc0 (after anywidget added as dependency)
anywidget v0.9.13
notebook v7.3.1
run the cell below twice
first output
second output
I suspect that, for an experienced Plotly developer, the change in the last example might be diagnostic (fingers crossed).
Of note, this issue doesn't arise when adding multiple datasets to the same
FigureWidget
instance; consider the following:Example 4: (expected behavior, post-anywidget)
plotly v6.0.0rc0
anywidget v0.9.13
notebook v7.3.1
cell 1
cell 2
cell 3
Any ideas on why having multiple
FigureWidget
instances would cause such erratic behavior following the adoption ofanywidget
?This is the official end of the issue, but I had gone through some additional examples and have included them below in case they're of use:
Example 5a: successful addition of image to both
FigureWidget
instances (expected behavior, pre-anywidget)plotly v5.24.1
anywidget not installed
notebook v7.3.1
cell 1
cell 2
Example 5b: unsuccessful addition of image to first
FigureWidget
instance but not second (unexpected behavior, post-anywidget)plotly v6.0.0rc0
anywidget v0.9.13
notebook v7.3.1
cell 1
cell 2
Example 6a: successful addition of image to second
FigureWidget
instance regardless of data added to firstFigureWidget
instance (expected behavior, pre-anywidget)plotly v5.24.1
anywidget not installed
notebook v7.3.1
cell 1
cell 2
Example 6b: unsuccessful addition of image to second
FigureWidget
instance regardless of data added to firstFigureWidget
instance (unexpected behavior, post-anywidget)plotly v6.0.0rc0
anywidget v0.9.13
notebook v7.3.1
cell 1
cell 2
The text was updated successfully, but these errors were encountered: