Home > Blockchain >  how to sort values in a horizontal bar graph that already has a variable
how to sort values in a horizontal bar graph that already has a variable

Time:03-24

enter image description hereHow do I sort the values based on top10[ActiveCases]? I don't seem to get the syntax right.

top10=df[0:21]
top10
plt.barh(top10['Country,Other'],width=top10['ActiveCases'])
plt.title("Top 10 countries with highest active cases")

CodePudding user response:

before creating the graph use

    top10 = top20
    top10.sort_values(by='ActiveCases')
    top10.head(10).plot(kind='barh')

this will plot the 10 highest countries

  • Related