Skip to content
Advertisement

Plot group averages for each rating on 4 separate plots

I have 4 groups (research, sales, manu, hr) and each group has 2 categories (0 & 1). I am trying to plot the average scores for each group in the features in the list ratings. The code that gives me the means looks like this (with depts = ['research', 'sales', 'manu', 'hr']:

JavaScript

Which results in this output:

JavaScript

My question is how do I plot these group means (research, sales, manu, hr) for each rating ['JobSatisfaction', 'PerformanceRating', 'EnvironmentSatisfaction', 'RelationshipSatisfaction']onto the 4 different bar graphs so I can visualize and compare the differences between each group?

My data is from the IBM HR dataset: https://www.kaggle.com/pavansubhasht/ibm-hr-analytics-attrition-dataset

Advertisement

Answer

You can use sns.barplot from seaborn, and since your y variable is comparable, separating by color and same y-axis is ok:

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement