Flipping horizontal bar chart to descending order

i’ve built a bar chart that is currently using a 'orientation = ‘h’ parameter to make it a horizontal bar chart instead of vertical. The bars go from left to right instead of bottom to top. This works fine but its building the chart with the smallest bar (lowest value) at the top, when i want it to be at the bottom. I’d like it to be in descending order.

Am wondering if there’s a way to do this without manipulating the data with pandas to be sorted in descending order.
Here’s the code I have. I’ve also attached an image. Thank you

def categoryChart():
    return { 'data': [
            x = count,
            y = category,
            orientation = 'h',
            marker = dict(
                line = dict(color='#ffffff', width=1)
        'layout': graph_objs.Layout(
            xaxis=dict(tickangle=-25, automargin=True),
            yaxis=dict(showticklabels=True, automargin=True),
            margin = dict(t=20, b= 20, r=10),

Use this in your layout.

(Your question is probably duplicate. There was a similar discussion with solution Horizontal Bar Charts)


awesome, this did the trick. thank you @caiyij

hi, great feature, but what if you have two horizontal bars, and want one of the be flipped, like attached Capture

figure = make_subplots(rows=1, cols=2,shared_yaxes=True)
		            x=[20, 14, 23, 15, 26, 37,12],
		            y=['a', 'b', 'c', 'd', 'e', 'f', 'g'], orientation='h'), row = 1, col = 1, )
	            x=[20, 14, 23, 15, 26, 37,12],
	            y=['a', 'b', 'c', 'd', 'e', 'f', 'g'], orientation='h' ),
				row = 1, 
				col = 2)
1 Like