Questions tagged [countplot]

seaborn.countplot shows the counts of observations in each categorical bin using bar. A count plot can be thought of as a histogram across a categorical, instead of quantitative, variable. Also use the seaborn tag.

17 questions
78
votes
3 answers

Order categories by count in a seaborn countplot

I know that seaborn.countplot has the attribute order which can be set to determine the order of the categories. But what I would like to do is have the categories be in order of descending count. I know that I can accomplish this by computing the…
Econ
  • 1,075
  • 1
  • 8
  • 13
68
votes
4 answers

How to prevent overlapping x-axis labels in sns.countplot

For the plot sns.countplot(x="HostRamSize",data=df) I got the following graph with x-axis label mixing together, how do I avoid this? Should I change the size of the graph to solve this problem?
william007
  • 17,375
  • 25
  • 118
  • 194
61
votes
7 answers

countplot with normalized y axis per group

I was wondering if it is possible to create a Seaborn count plot, but instead of actual counts on the y-axis, show the relative frequency (percentage) within its group (as specified with the hue parameter). I sort of fixed this with the following…
Lucas van Dijk
  • 799
  • 1
  • 7
  • 11
50
votes
3 answers

plotting value_counts() in seaborn barplot

I'm having trouble getting a barplot in seaborn. Here's my reproducible data: people = ['Hannah', 'Bethany', 'Kris', 'Alex', 'Earl', 'Lori'] reputation = ['awesome', 'cool', 'brilliant', 'meh', 'awesome', 'cool'] dictionary = dict(zip(people,…
AZhao
  • 13,617
  • 7
  • 31
  • 54
44
votes
3 answers

countplot() with frequencies

I have a Pandas DataFrame with a column called "AXLES", which can take an integer value between 3-12. I am trying to use Seaborn's countplot() option to achieve the following plot: left y axis shows the frequencies of these values occurring in the…
marillion
  • 10,618
  • 19
  • 48
  • 63
43
votes
2 answers

How do I plot two countplot graphs side by side?

I am trying to plot two countplots showing the counts of batting and bowling. I tried the following code: l=['batting_team','bowling_team'] for i in l: sns.countplot(high_scores[i]) mlt.show() But by using this , I am getting two plots one…
user517696
  • 2,472
  • 7
  • 24
  • 35
4
votes
2 answers

How to annotate countplot with percentages by category

Hi I'm trying to add percentages to my countplot with 5 categories and 2 values (old and younger). I've tried adding the def and loop from How to add percentages on top of bars in seaborn? My code: plt.figure(figsize =(7,5)) ax = sb.countplot(data =…
3
votes
1 answer

Issue in adding percentages to the top of bars in seaborn countplot

In a countplot I need to add percentages on top of the bars. I already tried the solution given in this post. But I am getting the percentage only for the first bar and not for the remaining. Is there any way to get it solved? Code snippet as…
2
votes
1 answer

How can I change the bar width in seaborn plots?

Each bar has large width How can I reduce the width of bars, as shown by the drawn red rectangles? I have the following code in Google Colab. model_names = ['RFC', 'KNN', 'D-tree', 'SVM RBF'] accuracies = [0.999, 0.970, 0.997,…
MMH.SE
  • 29
  • 3
2
votes
1 answer

Countplot of multilabel data

How can I make countplot of multilabel data? I have a pandas dataset with a column 'Genre'; there may be more than one genre for a movie. I need one countplot with bars for different classes (something that seaboorn.countplot would do). Genre …
diplodocus
  • 67
  • 1
  • 1
  • 7
0
votes
1 answer

catplot doesn´t display bars while importing a csv

I have made my own code trying to find any differences but I don´t know where is the trick, here is one catplot that display well: import matplotlib.pyplot as plt import seaborn as sns import pandas as pd # Change the color palette to "RdBu" par_ad…
0
votes
0 answers

Annotate bars without showing 0 values

I do not want to see the 0s being displayed in the countplot. Is there a way to eliminate showing just 0s from the labels on the graph? ax = sbn.countplot(data=df,x='link',hue='Status', width=0.2) for container in ax.containers: …
saas
  • 15
  • 1
  • 5
0
votes
2 answers

How do I add a percentage to a countplot?

I need to show a percentage for my bar graph. However I am not sure how to do it. sns.set_style('whitegrid') sns.countplot(y='type',data=df,palette='colorblind') plt.xlabel('Count') plt.ylabel('Type') plt.title('Movie Type in Disney+') plt.show()
0
votes
1 answer

How to separate countplot visualization with three features

I am trying to generate a frequency plot at different time frames with each time frame consists of four conditions and two possible outcomes, High or low. I can use hue to separate the four conditions but I also want to separate each condition with…
Lucho
  • 55
  • 1
  • 7
0
votes
1 answer

countplot of year from datetime

I m trying to use countplot with release date of movie in x axis where I need to use only the year to plot the graph.Please see the code and the graph below. sns.countplot(x=pd.DatetimeIndex(movie['release date']).year.drop_duplicates(),…
Ananya
  • 13
  • 3
1
2