Reputation: 75
I have a plotly express timeline, and I'm adding a scatter plot on the secondary y-axis, on top of the timeline bars. Because of the secondary_y, I have to use make_subplots, then add the traces from the Timeline figure to the main figure. This is working fine, except the category_orders breaks. If I plot fig_timeline directly, the category_orders work. But after placing the traces into the main figure, the categories appear in some random order. Any ideas how I can work around this?
fig = make_subplots(shared_xaxes=True, specs=[[{"secondary_y": True}]])
fig_timeline = px.timeline(df,
x_start='x_start',
x_end='x_end',
y='vm_type',
color='bartype',
category_orders={'vm_type':['a','b','c','d']},
hover_name='bartype',
)
for d in fig_timeline.data:
fig.add_trace(d)
Upvotes: 0
Views: 67