S
Solara14mo ago
artursp.

Keep zoom state of plotly figure when re-render is triggered.

I built an app where I have a coloured scatter plot with many thousand points each associated with an image from a set of classes. I can select points, look at the image and reclassify. When I want to re render my scatter plot so that it has the updated classes I change a reactive dataframe. This all works fine, the only issue is that I have to zoom into a region of the scatter plot to resolve the points. Re-rendering resets the axes so I have to find that region again (but I have to re-render regularly to keep track of which points I processed). So the question is if there is a way to update the scatter plot (i.e. the point colors) without resetting the axes.
3 Replies
Jochem Smit
Jochem Smit14mo ago
if you use plotly you can try something like this: https://github.com/Jhsmit/awesome-solara/blob/1643f0b04a92c31b2d87c8bede07cb01a21474ce/examples/plotly_update.py this is old code though not sure if it works and probably is not best practise
GitHub
awesome-solara/examples/plotly_update.py at 1643f0b04a92c31b2d87c8b...
Awesome solara showcase and examples. Contribute to Jhsmit/awesome-solara development by creating an account on GitHub.
MaartenBreddels
MaartenBreddels14mo ago
@artursp. can you maybe share example code so we can reproduce this?
pikaa
pikaa13mo ago
you can do this by using the on_relayout callback in FigurePlotly by saving the key relayout information (x/y range), then calling upon it when you need it for a redraw

Did you find this page helpful?