plotly python 如何显示 y 值为零的条形图

plotly python how to show bars where y values are zero

即使该条的 y 值为零,我仍想显示所有 x 轴值。我在这里做错了什么?

import plotly.express as px
import plotly.io as pio

threshold_one = ['13%', '13%', '13%', "34%", "34%", "34%", "55%", "55%", "55%"]
threshold_two = ["15%", "37.5%", "60%", "15%", "37.5%", "60%", "15%", "37.5%", "60%"]
y_values = [5500,5267,5466,345,356,375,0,0,0]


df = pd.DataFrame({'threshold_one': threshold_one, 'threshold_two': threshold_two, 'y_values': y_values})

fig = px.histogram(df, x="threshold_one", y="y_values",
         color="threshold_two",
         barmode = 'group')

fig.show()

如您所见,x 轴阈值 one = 55% 从 x 轴中丢失,但我希望它仍然存在,即使 y 值为 0。

提前致谢

使用 px.bar 而不是 px.histogram

import plotly.express as px

threshold_one = ['13%', '13%', '13%', "34%", "34%", "34%", "55%", "55%", "55%"]
threshold_two = ["15%", "37.5%", "60%", "15%", "37.5%", "60%", "15%", "37.5%", "60%"]
y_values = [5500,5267,5466,345,356,375,0,0,0]


df = pd.DataFrame({'threshold_one': threshold_one, 'threshold_two': threshold_two, 'y_values': y_values})

fig = px.bar(df, x="threshold_one", y="y_values",
         color="threshold_two",
         barmode = 'group')

fig.show()