Bar chart, barmode-relative, barwidth not shown - MRE provided

Hello,

I’m having issue with relative barmode and width.

For instance this code is fine:

fig = go.Figure(layout=go.Layout(
    title='SomeTest',
    yaxis2=dict(title='Test', domain=[0.25, 0.95]),
    yaxis=dict(title='Test', domain=[0, 0.2]),
    xaxis=dict(title='Time'),
    legend=dict(x=0, y=1),
    barmode="relative"
))

fig.add_trace(go.Bar(
    x=["2020-12-31", "2021-01-31"],
    y=[3,7],
    name="SOmeName",
    yaxis="y2",
))   
fig.show()

It gives me:
image

But as soon as I want to change the width of the bars, and therefore write:

fig = go.Figure(layout=go.Layout(
    title='SomeTest',
    yaxis2=dict(title='Test', domain=[0.25, 0.95]),
    yaxis=dict(title='Test', domain=[0, 0.2]),
    xaxis=dict(title='Time'),
    legend=dict(x=0, y=1),
    barmode="relative"
))
fig.add_trace(go.Bar(
    x=["2020-12-31", "2021-01-31"],
    y=[3,7],
    name="SOmeName",
    yaxis="y2",  # y or y2 does not change anything
    width=0.6
))   
fig.show()

Then I get this:
image

If I copy paste an example from the doc, and modify it a bit, as below:

x = [1, 2, 3, 4]

fig3 = go.Figure()
fig3.add_trace(go.Bar(x=x, y=[1, 4, 9, 16]))
fig3.add_trace(go.Bar(x=x, y=[6, -8, -4.5, 8], width=0.4))
fig3.add_trace(go.Bar(x=x, y=[-15, -3, 4.5, -8]))
fig3.add_trace(go.Bar(x=x, y=[-1, 3, -3, -4], width=0.3))

fig3.update_layout(barmode='relative', title_text='Relative Barmode')
fig3.show()

Then I get this:

So, it should work. Why does my first example fails to render the bars ?

It seems that if I specify the type of the xaxis (for instance to “category”), it fixes the problem.
→ It does fix it as width of a category is 1, while the values on the xaxis were initially strings representing dates → datetime xaxis → width in milliseconds

The width is relative to the x-axis. In your case with dates, the underlying values for the x-axis are milliseconds so 0.6ms would be very very small/invisible at a year scale. (In the case of category x-axis, the unit between each category is 1)

1 month is about 2.6 billion milliseconds so if you want a width of 0.6, try 0.6*2.6*10e9

Ha ! Right, xaxis strings converted to datetime. Thanks. Going to remove the bug flag. Thanks