How to change order of horizontal bar Chart y-axis values

I am not able to change the order of y-axis values in horizontal bar chart.


 fig =
        title="Top 10 cities which are badly affected by Terrorism",
        labels={"index": "Cities", "value": "Attack Counts "},
        color_continuous_scale=["#bdbdbd", "#969696", "#737373", "#525252",],

Chart looks like this:

I just want this thing in reverse order in graph. The higher value in top and lower in bottom.

@empet any help here pls?

PX plots values in the order they appear in the data frame, so one option would be to sort your inputs. Alternatively, you can use the category_orders keyword argument to force the bars into any given specific order.

Finally, you can use the approach documented here :

1 Like