Plotly: How to prevent graphs from going blank when there are too many interactive plots?

Viewed 830

I have no idea why this happens but when I plot more than 9 graphs, the plots go blank starting from the 1st one.

So let's say I plot 10 graphs, which each of them has 8 subplots, plots go blank excluding the 1st and last subplot. When I plot 11 graphs, 1st and 2nd plots go blank.

The code below works perfect but too many graphs breaks previous plots.

days = df["DATE"].dt.floor("D").unique()
# create axis for each day
fig = plotly.subplots.make_subplots(len(days), subplot_titles=subplot_titles, vertical_spacing=0.03)


for i,d in enumerate(days):
    
    mask = (df["DATE"].dt.floor("D")==d)&(df["IOT_ID"]==iot_id)
    
    splt= px.line(df.loc[mask], x="DATE", y="Vibration")
    
    if len(list(splt.select_traces())) > 0:
        fig.add_trace(list(splt.select_traces())[0], row=i+1, col=1)
        


fig.update_layout(
    autosize=False,
    width=1000,
    height=5000
                )
fig.update_layout(title = "IoT ID = " + iot_id + ",  Titreşim")
fig.show()

I sort of solved this problem by changing the renderer to a non - interactive one.

Such as

fig.show(renderer="svg", width=1000, height=5000)

But it would be better if all of the plots are interactive

Is this a technical problem or is there a way to make many interactive plots ?

1 Answers

Now that I know you're running plotly in a Jupyter Notebook. JupyterLab, perhaps? This is quite possibly a memory issue. JupyterLab has a default max buffer size stored in:

C:\Users\<YOU>\.jupyter\jupyter_notebook_config.py

If you're running JupyterLab you can find and edit this file using:

jupyter lab --generate-config

And similarly for a Jupyter Notebook you've got

jupyter notebook --generate-config

Running that line in a command window returns:

Overwrite C:\Users\<YOU>\.jupyter\jupyter_notebook_config.py with default config? [y/N]

I usually opt for [N] and rather open that file directly in the provided folder and edit the values from there. On my end the relevant parts of the file looks like this:

## Gets or sets the maximum amount of memory, in bytes, that is allocated  for
#  use by the buffer manager.
c.NotebookApp.max_buffer_size = 18000000000

And you can change that value directly, save it, and launch JupyterLab again.

Related