clicktoshow not working for annotations on log scale
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
The click event does not seem to be triggered when clicking on an annotated point (even after waiting for the hover text to show up indicating that the point "has been found"). In the example below, the annotation cannot be toggled. With linear axes scaling (dropping the log_x|y and not rescaling x|y=np.log10...) the annotation toggling works as expected.
This bug is probably related to the (forced / unnatural) requirement to rescale the (x,y) coordinates of annotations (see #2580)
x = np.arange(1,5)
df = pd.DataFrame(data={'x':x,'y':x**2,'z':x**3,})
fig = px.line(df,
x='x',
y=['y','z'],
log_x=True,
log_y=True,
)
annotations = []
fig.for_each_trace(
lambda trace: annotations.append(dict(x=np.log10(trace.x[-1]),
y=np.log10(trace.y[-1]),
text=f'({trace.x[-1]:g},{trace.y[-1]:g})',
clicktoshow='onoff',
visible=True,
opacity=0.5,
))
)
fig.update_layout(annotations=annotations,
width=300,
height=300,
)
fig.show()

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 provided Python example with logarithmic axes and compare it with the linear-axis version. Trace how annotation coordinates are rescaled and how clicktoshow handles clicks on annotated points, including the related context in #2580. Done means the annotation toggles when clicked on log-scaled plots without regressing linear scaling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100