Bars in Chart are not displayed in right order!

Hello,

I wanted to create a Timeline/Gantt-Chart.
As you can see I have two colors/groups for bars: Release and Epic.
In my DataFrame the order is right: Releases and Epics are mixed together.

However, my Gantt-Chart sorts the Epics on the buttom of the Chart and Releases on the top:

Does anyone how I can avoid that? I want my Chart to display exactly the order of my DataFrame.

I defined my timeline as follows:

fig = px.timeline(df
                      , x_start="Start"
                      , x_end="End"
                      , y="Name"
                      , hover_name="Task"
                      , opacity=0.8
                      , template='plotly_white'
                      , height=3000
                      , width=1150
                      , color="Type"
                      )

The reason for that is that when you specify volor, it creates 2 traces: one with Epic data, and one with Release data. The order of the y-axis is first all the ones of type Epic, then the Release ones.

You can manually specify the order of a given category, in your case so it follows the original dataframe.

px.timeline(
    # your arguments
    category_orders=dict(
        Name=df["Name"].drop_duplicates().tolist()
    )
)
1 Like

Thank you! This works perfectly fine!