plotly.py
plotly.py copied to clipboard
textposition="auto" doesn't show texts for 0 values
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()
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.
@chaosink I agree with @archmoj that this is a feature rather than a bug - may I close the issue?