Multiple Surface Plots crashing



I’m drawing multiple curved surfaces as part of a general 3D cone shape - see codepen above.

The codepen is only drawing 50 of the surfaces (see line 2710, feel free to have it try to load all the surfaces), I have about 300 in this case and up to 2-3k in others (number of data sections) - but whenever I try to load more than a certain amount (on my machine is 150, seems like it depends on how much RAM one has available) the plot just crashes which I’m assuming means it went out of memory.

The surface data is generated in python to use numpy functions, then embedded in the javascript. I run into this same issue with the python plotly library as well.

My question is - is this normal/expected behavior based on the number of surface glyphs I have? Is there any way I can optimize this so it uses less memory per surface plot so I can draw more without it crashing? I’m fine without lighting if that helps at all. If this is just a limitation of plotly’s rendering I would love to try to optimize this in the code if pointed in the right direction.

I know drawing multiple surfaces might not be ideal as it could just be one single surface but I could not find a way to finagle surfacecolor to get it to achieve the same effect I have here (for each “bin” or section of data, it has a color based on a color range that is not the Z value - I tried to use surfacecolor but it was just one giant blended together soup of colors that looked different depending on what angle you were looking at it, instead of nice discrete sections).

Thanks for writing in.

It’s hard to say whether your observations are expected. Those things will always depend on one’s hardware. One thing is sure, given a fixed number of total data points, performance improves as the number of traces go down. In your case, (300 * 3000) = 9e5 should be ok for plotly.js if plotted in a single surface. Beyond that, our 3d renderer will probably start to feel sluggish on most hardware.

So in brief, you should try to combine your traces into one.

As for

I invite you to read Colors for discrete ranges in heatmaps - #4 by empet

where a solution is given for creating custom “discrete” colorscales (that example shows off heatmap traces, but should work for surface traces as well)