Position scatter x points overlaying barchart with n groups

Hello Ploty Community and Plotly Team,

Thanks a lot for this well customisable graphing library. I use it a lot for my work and it has a great contribution to my work.

To see how bar charts change over time I have started to overlay bar charts with scatter points that have different shapes (representing two periods I compare my current bar chart too). See this Screenshot for an example
Screenshot 2020-05-29 at 11.31.45.

Basically, I offset the x-position for the scatter points according to the bar they belong to.

Now I want to extend a more generic function that works with n groups, but I struggle do achieve this as there is no clear pattern to me after which plotly sets the bar chart coordinates (see the following screenshot). My

Do you have any suggestions for this problem? I’ve tried to control the positiong more through width and offset, but I have not come to a clear working solution yet. Maybe you guys have some input for me.

Thanks and I can deliver more code, if needed.

All the best.

Obsolet. I had an error in my code. Now, it works as suppoed to.