textposition="auto" doesn't show texts for 0 values · Issue #4686 · plotly/plotly.py · GitHub
Skip to content

textposition="auto" doesn't show texts for 0 values #4686

Open

Description

@chaosink
import pandas as pd
import plotly.graph_objects as go

df = pd.DataFrame(
    {
        "A": [5, 0, 7],
        "B": [5, 0, 7],
    },
    index=[1, 2, 3],
)

fig = go.Figure(
    data=[
        go.Bar(
            name="A",
            x=df.index,
            y=df["A"],
            text=df["A"],
            textposition="auto",
        ),
        go.Bar(
            name="B",
            x=df.index,
            y=df["B"],
            text=df["B"],
            textposition="outside",
        ),
    ]
)

fig.update_layout(
    xaxis_title=None,
    yaxis_title=None,
    legend_title=None,
)

fig.show()

newplot

Activity

  1. archmoj commented on Jul 24, 2024

    @archmoj
    Contributor

    I'm not sure we should consider this a bug.
    Here is a codepen illustrating the graph using plotly.js.
    You could use an array to specify desirable textposition as illustrated in this codepen.

  2. gvwilson commented on Jul 26, 2024

    @gvwilson
    Contributor

    @chaosink I agree with @archmoj that this is a feature rather than a bug - may I close the issue?

  3. emilykl commented on Sep 1, 2026

    @emilykl
    Contributor

    Equivalent plotly.js issue: plotly/plotly.js#6474

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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