How to limit bar width with time-series axis

Hi,

you have a strange way of putting your Figure together mixing up plotly.express and plotly.graph_objects

Here is how I would do this, the width parameter is what you are looking for. Since you are using a time axis, the width has to be specified in milliseconds:

from pandas import DataFrame
import plotly.graph_objects as go

dtf = DataFrame({"hour": ["2023-07-10 17:00:00+08:00", "2023-07-10 21:00:00+08:00"], "number": [2, 5]})
fig = go.Figure(go.Bar(x=dtf.hour, y=dtf.number, width=3_600_000))

fig.show()


mrep time axis