plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

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

Open chaosink opened this issue 1 year ago • 2 comments
trafficstars

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

chaosink avatar Jul 23 '24 04:07 chaosink

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.

archmoj avatar Jul 24 '24 14:07 archmoj

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

gvwilson avatar Jul 26 '24 13:07 gvwilson