Multiple bars on same line (horizontal)

I am using go.Bar (horizontal) to create a timeline chart of sorts, using base and x to define the position and span of each bar.
I’m doing this in a a multi-plot graph (with make_subplots), because I want to be able to create distinct “lanes” with different heights (based on the number of associated data points).

It looks like this:

However, I need to be able to add multiple bars in the same row for the same “lane”.
Essentially, to achieve something similar to the grouping that can be achieved with px.timeline or the old ff.create_chart

Since I’m in a subplot situation, I cannot however use either of those (nor can I use facets in plotly express as all subplots would then show all values for the y axis, and have the same heights).

I’ve not discovered a way to control go.Bar to do this. Am I missing something? I’m assuming px.timeline uses that under the hood though…

And obviously as soon as I had written it down, it came to me. Sometimes it just requires an interlocutory (even a silent one) that you need to explain the problem to, to re-organise your thoughts enough that the solution presents itself to you…
Let’s still keep the question with an answer for future me, who’s sure to ask it again…

In the timeline graph, I assign a y value that’s just a number. By setting the same y value to all bars that need to be on the same line, I get the desired behaviour (although obviously those bars can overlap if the data overlaps).

That simple…

1 Like