✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Is it possible to change shapes without replotting the whole figure? Or otherwise improve performance?


I’ve got a heatmap that takes a fair amount of time to render (about 10s, I’m already using a subset of the data). I’m visualising a user-selected region by drawing a rectangle shape inside the layout for the figure. Like this: https://plot.ly/python/shapes/ . So every time the user changes the region is takes about 10s to visualise it… this is obviously kind of frustrating.

I tried to speed things up by putting the old figure state into the callback; if only the selected region has changed then I re-use the “data” part from the old figure and only update the “layout”. This doesn’t seem to actually speed things up, though… I guess most of this time is rendering, not creating the Heatmap object. Looking here: Is it possible to update just `layout`, not whole `figure` of Graph in callback? indicates that this should have been obvious… but when I saw the “uid” hiding inside the “data” I thought maybe dash would figure out that the data was identical and save some time.

Two questions:

  • The above post is a year old… has updating layout-only been implemented by chance, and I just haven’t found the documentation on it?

  • Given this isn’t possible, is there a smarter way to draw a rectangle on top of an existing figure? I could put two axis on top of each other in the same figure (like this: https://plot.ly/python/graphing-multiple-chart-types/ ), but I’ll still need to render the whole figure in the callback, so I don’t think that will help. A complete second figure with transparent background would do it… but I’m not nearly good enough with CSS etc. to get them to line up on top of each other…


1 Like

Hi @Veenstra,

Were you able to figure out a better way to update the shapes?

Looking into the same things now, any help would be appreciated!

Thank you,

Never did. I ended up giving up and going a different route for our data visualization. Not sure if things are different now…

1 Like