Skip to content

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

Open
@JohnorJohnny

Description

@JohnorJohnny

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions