✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Cannot sort numerical category bar chart based on y value

I want the bar chart on the left (row 1, col 1) is sorted based on the y values. Instead it automaticaly ordered based on x values. See the code as follow,

fig = make_subplots(rows=1, cols=2)
fig.add_trace(go.Bar(x=[2, 5, 1, 3, 4], y=[ 7049, 8410, 18306, 24047, 26736]),row=1, col=1)
fig.add_trace(go.Bar(x=[20, 30, 40], y=[50, 60, 70]),row=1, col=2)
fig.update_layout(height=600, width=1200, title_text=“Subplots”)
fig.show()

Hi @aiswra,

To get data plottted in your given order, set x data of categorical type, i.e.:

fig.update_layout( xaxis_type='category')