Adding N annotations takes O(N^2) time
Open
Nobody has claimed this yet.
bug
P2
performance
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
Plotly is unreasonably slow to add more than a few hundred annotations to a plot. This code
import time
import plotly
fig = plotly.graph_objects.Figure()
NUM_ANNOTATIONS=1000
start_time = time.monotonic()
for i in range(NUM_ANNOTATIONS):
fig.add_annotation(
x=i,
y=time.monotonic() - start_time,
text=str(i),
)
print(i)
fig.update_layout(
xaxis_range=[0,NUM_ANNOTATIONS],
yaxis_range=[0,time.monotonic() - start_time],
xaxis_title_text="# Annotations",
yaxis_title_text="Cumulative Time [s]",
)
fig.show()
produces this plot
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction in the issue and profiling the repeated fig.add_annotation calls. Trace the Python Figure annotation path to identify where the cumulative cost grows, then verify that adding many annotations no longer shows quadratic behavior using the same script.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100