Skip to content

Y-axis tickformat='+' causes unexpected scientific notation for zero tick #5152

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

Open
JohnorJohnny opened this issue Apr 24, 2025 · 0 comments

Comments

@JohnorJohnny
Copy link

JohnorJohnny commented Apr 24, 2025

Hi Plotly team,

I'm encountering an issue when trying to display the sign for all Y-axis tick labels using the tickformat='+' format. Specifically, when the Y-axis includes a tick near zero, Plotly displays it in scientific notation instead of as +.

Problem

Setting tickformat='+' on the Y-axis leads to unexpected tick labels like -8.881784197e-17, which appears instead of a clean +0. This seems to be due to floating-point precision errors, but it's surprising that it breaks the format hint and drops into scientific notation.

Minimal reproducible example

import plotly.graph_objects as go

figure = go.Figure()

figure.add_scatter(
    x=[1],
    y=[0.58],
)

figure.update_layout(
    yaxis={
        'range': [-0.66, 0.66],
        'tickformat': '+',
    },
)

figure.show()
Image

Expected Behavior

All tick labels on the Y-axis should respect the + format and include a sign, including zero. The tick at (or near) zero should be displayed as +0, not in scientific notation.

Thanks for the awesome work on Plotly!

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

1 participant