-
Notifications
You must be signed in to change notification settings - Fork 892
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Hi!
I stumbled upon something where I think marimo has a bug in showing the figure created by plotly.
If one draws shapes over a figure in plotly, those shapes do not vanish afterwards, even though the figure itself does not hold any shapes anymore.
I attached a small reproducer: note that at first calculation of all the cells, there is no rectangle on top of the image. It appears after ticking the checkbox on. But it does not get removed after ticking the checkbox off, even though the figure has an empty shape attribute.
This seems to be a normal plotly use-case, as demonstrated here.
Will you submit a PR?
- Yes
Environment
Details
{
"marimo": "0.19.4",
"editable": false,
"location": "project/.pixi/envs/default/lib/python3.13/site-packages/marimo",
"OS": "Linux",
"OS Version": "6.8.0-51-generic",
"Processor": "x86_64",
"Python Version": "3.13.5",
"Locale": "en_US",
"Binaries": {
"Browser": "--",
"Node": "--"
},
"Dependencies": {
"click": "8.2.1",
"docutils": "0.22.4",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.8.2",
"narwhals": "2.15.0",
"packaging": "25.0",
"psutil": "7.0.0",
"pygments": "2.19.2",
"pymdown-extensions": "10.16.1",
"pyyaml": "6.0.2",
"starlette": "0.52.1",
"tomlkit": "0.14.0",
"typing-extensions": "4.15.0",
"uvicorn": "0.40.0",
"websockets": "16.0"
},
"Optional Dependencies": {
"loro": "1.10.3",
"pandas": "3.0.0",
"polars": "1.37.1"
},
"Experimental Flags": {}
}
Code to reproduce
import marimo
__generated_with = "0.19.4"
app = marimo.App(width="medium")
@app.cell
def _():
import marimo as mo
return (mo,)
@app.cell
def _():
import plotly.express as px
import numpy as np
return np, px
@app.cell
def _(mo):
plot_boxes = mo.ui.checkbox(label="Plot boxes", value=False)
return (plot_boxes,)
@app.cell
def _(plot_boxes):
plot_boxes
return
@app.cell
def _(np, plot_boxes, px):
img_rgb = np.array([[[255, 0, 0], [0, 255, 0], [0, 0, 255]],
[[0, 255, 0], [0, 0, 255], [255, 0, 0]]
], dtype=np.uint8)
fig = px.imshow(img_rgb)
if plot_boxes.value:
fig.add_shape(type="rect",
xref="paper", yref="paper",
x0=0.4, y0=0.4,
x1=0.6, y1=0.6,
line=dict(
color="Red",
width=3,
)
)
fig.update_layout(
dragmode='drawrect',
newshape=dict(line_color='cyan'))
fig
return (fig,)
@app.cell
def _(fig):
fig.layout.shapes
return
if __name__ == "__main__":
app.run()
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working