Blackdynomite
Blackdynomite

Reputation: 431

Simple Problem with Seaborn Barchart Plotting

Relatively simply issue here but I have a simple dataframe like so:

df.head()

     trigger       count
0   task_appeared   8677
1   status          7410
2   task_created    4046
3   custom_field    2550
4   on_due_date      2116

And I want to print out a descending seaborn visual to show the list of trigger types by count in descending order. My code is as follow:

sns.countplot(x = "trigger", data = df,palette = 'plasma')
             

plt.title("Trigger Popularity")
plt.ylabel("Count of Triggers")
plt.xlabel("Trigger Type")
plt.xticks(rotation=90)

However I just get the following visual. It does not show the correct value counts for each trigger in descending order as listed from my original dataframe. I dont know why the y-axis only shows values from 0 to 1 when it should show the value specified by the count column of the DF

Image of Trigger Pop But should be descending from 8677

Upvotes: 1

Views: 45

Answers (1)

Subbu VidyaSekar
Subbu VidyaSekar

Reputation: 2615

Already you did the count of each trigger types

so you can use barplot

sns.barplot(x="trigger", y="count", data=df)
plt.xticks(rotation=90)
plt.title("Trigger Popularity")

Output:

enter image description here

Upvotes: 2

Related Questions