Flipping horizontal bar chart to descending order


#1

hi!
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': [
        graph_objs.Bar(
            x = count,
            y = category,
            orientation = 'h',
            marker = dict(
                line = dict(color='#ffffff', width=1)
                ),
            ),
        ],
        'layout': graph_objs.Layout(
            font=dict(size=10),
            xaxis=dict(tickangle=-25, automargin=True),
            yaxis=dict(showticklabels=True, automargin=True),
            margin = dict(t=20, b= 20, r=10),
            )
        }

#2
yaxis=dict(autorange="reversed")

Use this in your layout.

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


#3

awesome, this did the trick. thank you @caiyij