Skip to content

write_image hangs with large amount of data #419

@J-oseph

Description

@J-oseph

The function write_image hangs when trying to export a Figure with too many data points.
There seems to be a limit where the function goes from taking <10 seconds to hanging by adding an extra point.

On my machine on Windows, the limit is 4,914,834. Exporting 4,914,833 takes only 5 seconds in comparison.

import plotly.graph_objects as go
import numpy as np

NUM_DATAPOINTS = 4_914_834  # the magical threshold
fig = go.Figure(data=[go.Scatter(x=np.repeat(1.0, NUM_DATAPOINTS), y=np.repeat(0.5, NUM_DATAPOINTS))])
fig.write_image("output.png")

Using arrays of ints instead of floats increases the limit.

When plotting 1000 lines in the Figure (same total datapoints) instead of one as above, the "limit" decreases by about 4k.

Windows 11
Python 3.14.0
kaleido==1.2.0
plotly==6.5.0
Chrome for Testing v135.0.7011.0 (installed with kaleido_get_chrome)

I also replicated the issue in an Ubuntu 24.04 VM. One time it threw a Timeout exception but I wasn't able to replicate it again.
The datapoint limit here was closer to 4.8 million.

Ubuntu 24.04.
Python 3.14.0
kaleido==1.2.0
plotly==6.5.0
Chrome for Testing v135.0.7011.0 (installed with kaleido_get_chrome)

Thank you!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions