Skip to content

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

Open
@chaosink

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

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