How to properly create and update a Figurewidget object from a imshow plot with facets?

35 Views Asked by At

When using plotly express imshow with facet_col, the returned figure has more than one trace. How can this figure be properly added to a Figurewidget object and later on be updated with new data? This is what I have tried and not working due to: Exception: In order to reference traces by row and column, you must first use plotly.tools.make_subplots to create the figure with a subplot grid.

px_fig = px.imshow(
        imgs[:, :, :],
        binary_string=False,
        zmin=0,
        zmax=1,
        facet_col=0,
        aspect="auto",
        facet_col_wrap=20,
        facet_row_spacing=0.02,
        facet_col_spacing=0.005,
        color_continuous_scale='jet',
    )

o_samplesviz = go.FigureWidget()
subplots = make_subplots(rows=len(rows), cols=len(col_list))
subplots.add_traces(data=px_fig.data, rows=row_list, cols=col_list)
o_samplesviz.add_traces(subplots.data, rows=row_list, cols=col_list)

The goal is to create like a grid of heatmaps which is what imshow plot is returning, have that grid in a go.Figurewidget object so I can integrate that with ipywidgets.

Thanks

0

There are 0 best solutions below