I am trying to use ‘categoryorder’ and ‘categoryarray’ in the layout to sort the sequence. The sequence can be sorted without any problems and shown perfectly fine on the bar chart. However, when I pass a series (same keys as categoryarray’ to the trace data, the sequence seems not matching with the ‘layout’. Is there a way to match them?
Here is the code:
'data': [
go.Bar(
x=df4_rate,
y=df4_rate.index,
error_x=dict(
type='data',
symmetric=False,
array=df4_confint[1].subtract(df4_rate),
arrayminus=df4_rate.subtract(df4_confint[0]),
visible=True
),
orientation='h',
name=org_name,
text=pval_array,
hoverinfo = 'text',
marker=dict(
color='#711471'
)
)
],
'layout': go.Layout(
xaxis={
'range': [0, 1]
},
yaxis={
'showticklabels': True,
'categoryorder': "array",
'categoryarray': pval_array.keys(),
},
margin={'l': 300, 'b': 50, 't': 50, 'r': 0},
height=600,
hovermode='closest',
barmode='group',
)