I made a plot which has dates (end of month dates) on the x-axis.
The plot has one trace that is a scatter,
and two traces that are bars.
In layout I set barmode: “stacked”
The desired result:
I would like the bars to have no gaps between them.
The problems:
I tried using bargap: 0 in layout. It does work almost ok, but there is still a gap between most of the bars. I think the gap width is being set to 28 days (the minimum), because January-February bars are displayed ok, but the rest not.
I tried instead setting width: 1 or 31 in the data traces, but then there is no bar whatsoever being displayed
Seems like the bars should always have the same width. Since the February one is only 28 days large, the others scale with it.
If you are willing to aggregate per month, here is one way to solve it:
Give a width of 1000 * 3600 * 24 * 31, which is the maximum of milliseconds in the month.
Edit: As pointed by ajoposor, there is now an overlap of the bars.
To get rid of it, provide the width independently for each bar. Quite annoying if you take leap years into account, but doasabe.
It is a way to deal with the gaps. However, now instead of gaps, there are overlaps in the bars.
Based on your example, I noticed that there is some bug in the math for setting the mid point of the next month. For instance, the mid-point for February is set based on the number of days of the preceding month, i.e., 31, That’s why the overlap is greater on the right side than the left side if you set February to have 35 days (when set to 31, there’s only a right side overlap.
I think your problem is caused by type of column which is set to xaxis. If it is datetime and you have values only for first day of month it is not possible to have the same bargaps, since there is different distance between bars. Try to change your datetime column to string.