0

I have been working on a campus recruitment dataset. The target variable in the dataset is "status", which indicates if the student is placed or not. Now, I am comparing each variable (for e.g. gender) with the target variable (status of placement), to know which variable affects the target variable the most. To compare two variables, I have been using countplots in seaborn. The plot for the variable "gender" looks like this.

Image showing the sns plot

The code for the sns plot is as follows:

ax = sns.countplot(x = "cat_degree_t", hue = "status", order = df['cat_degree_t'].value_counts().index, data = df);
abs_values = df["cat_degree_t"].value_counts().values;
ax.bar_label(container=ax.containers[0], labels=abs_values);

Now I want to know how I could add values of individual bars in the countplot (not the total value like already written in the figure shown above, but on every individual bar). This would help me find out the percentage of placed and not placed for each category in the variable "gender".

Any help would be really appreciated.

Thanks

  • Maybe `sns.histplot(...., hue=..., discrete=True, mulitple='fill')` helps to show percentages per hue for each x-value? – JohanC Dec 31 '21 at 18:54

0 Answers0