Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations referenced to the y-axis are in the wrong place, for log-scales #6880

Closed
RichardNeill opened this issue Feb 2, 2024 · 3 comments
Assignees

Comments

@RichardNeill
Copy link

If I have:

  • a point at value y=3
  • an annotation at value y=3, with yref=y
    then the annotation is attached to the point, as expected.

But If I then make the y-axis have type=log, then the annotation comes adrift from the point.
https://codepen.io/RichardNeill/pen/dyreyMG

What's happening is that the annotation is being drawn in linear units - it isn't truly referenced to the yaxis, because if you read across, the y-value for the annotation is 10E3, not 3.

This might be a problem to fix, given that it would be backward-incompatible - see #420.
If so, please at least consider warning about this issue at: https://plotly.com/javascript/text-and-annotations/
A suitable message might be:

Note, for backward compatibility, annotations are drawn in linear units. So if your axis-type is log, remember to use:
yref:y, y:Math.log10(your_y_value)

Thanks :-)

@alexcjohnson
Copy link
Collaborator

You're exactly right @RichardNeill - an unfortunate decision very early in the history of plotly.js 😅

@LiamConnors thoughts on how best to warn people about this? We do already mention this in the description for x and y, but you'll only see that if you look carefully at the reference for these attributes:

'If the axis `type` is *log*, then you must take the',
'log of your desired range.',

@LiamConnors
Copy link
Member

Yeah, we could add an example to the annotations page of what that would look like with a log axis. Will add it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants