Bar chart spillover with sparse data

I am plotting some basic bar charts over time and I have a bar width problem when there are few bars in the graph. Take this sample data for example.

Date, Value
Jul 18, 1
Aug 5, 1

When I plot fig =, x=‘date’, y=‘value’), the resulting graph should have bars that are only one day wide each but the figure is stretched by default to fill up the entire graph area. The Jul 18 bar should only be for Jul 18 but it spills over into other days from Jul 11 to Jul 25

How do I make it so that the bar for each day is exactly one day wide? It should look something like this

I know it is possible to hard code a high bargap in update_layout for this sparse example but I would prefer a more flexible solution which shows the appropriate bar width (1 day wide) no matter how many bars there are in the graph. If I set a high bargap, graphs with a lot of bars would then have unnecessarily narrow bar width.

You can set the bar width if you like, or you can set the x axis to period mode with a period of 1 day. Time Series and Date Axes | Python | Plotly