1

I want to create a large number of Scatter3d plots in a plotly subplots array. When I plot 16 or fewer plots, everything renders correctly, but when I try to plot e.g. 25 plots in a 5x5 array, only the last 16 plots are rendered.

How can I get more than 16 plots to render correctly?

16 plots out of 25 render correctly

Running the code below produces the problem demonstrated in the screenshot above. However, if you edit line 7 to read nrow,ncol = 4,4 then 16 plots render correctly. This problem does not seem to occur with other plot types (e.g. Scatter).

from plotly.subplots import make_subplots
import plotly.graph_objects as go

import numpy as np

Npts = 30
nrows,ncols = 5,5
speclist = [[{"type": "Scatter3d"} for i in range(0,ncols)] for j in range(0,nrows)]

fig = make_subplots(rows=nrows,cols=ncols,specs=speclist)

for i in range(0,nrows*ncols):
    row,col = (i//ncols)+1,(i%ncols)+1
    print("Index: {i:02d} Row: {row:02d} Column: {col:02d}".format(i=i,row=row,col=col))
    xvals=np.random.uniform(0.0,1.0,Npts)
    yvals=np.random.uniform(0.0,1.0,Npts)
    zvals=np.random.uniform(0.0,1.0,Npts)
    fig.add_trace(go.Scatter3d(x=xvals, y=yvals, z=zvals,mode='markers',showlegend=False),row=row,col=col)

fig.show()
CnrL
  • 2,558
  • 21
  • 28
  • 3
    See the console warnings "_Too many active WebGL contexts. Oldest context will be lost_" and the subsequent errors. This is a browser limitation, on Chrome the number of WebGL contexts is limited to 16. There is an opened [issue](https://github.com/plotly/plotly.js/issues/2333) about this. – EricLavault Jun 21 '23 at 15:56

0 Answers0