Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Open
@JohnorJohnny

Description

@JohnorJohnny
Issue body actions

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

    P3backlogbacklogbugsomething brokensomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.