Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Obscene memory usage in rendered page (fig.to_html) containing many subplots

When I make 100 subplots, each showing 1000 datapoints and render to html, it yields a 5.9MB file which takes up ~5GB of RAM when loaded in google chrome (Version 94.0.4606.54, 64-bit) on Ubuntu 20.04.

Minimal code:

import numpy as np
import plotly.graph_objects as go
import plotly.subplots as ps


y = np.random.rand(1000)

num_subplots = 100

fig = ps.make_subplots(rows=num_subplots, cols=1)
fig.update_layout(height=200 * num_subplots, showlegend=False)

for i in range(num_subplots):
    scatter = go.Scattergl(x=np.arange(len(y)), y=y, mode="lines", line=dict(color="#000000"))
    fig.add_trace(scatter, row=i + 1, col=1)

with open(f"{num_subplots}_subplots.html", "w") as f:
    f.write(fig.to_html(full_html=True))

Memory usage upon load and unload in chrome

Why is the memory usage here so high? Is there any workaround to this?