I have a dataframe with some data. See screenshot below.
As shown the dataframe is already sorted in descending order. I then use the below code to build a horizontal barchart.
import plotly.graph_objects as go
test = df.head(10).copy()
fig = go.Figure(go.Bar(x=test['Published_Count'], y=test['Author'], orientation='h'))
fig.update_layout(barmode='stack', yaxis={'categoryorder':'total descending'})
fig.show()
The output I get is
I tried this with plotly express as well:
import plotly.express as px
test = df.head(10).copy()
fig = px.bar(test, x="Published_Count", y="Author", orientation='h')
fig.show()
What am I doing wrong? I tried categoryorder, categoryarray and everything I could find.