Skip to content

Commit 63273ea

Browse files
authored
Create Stacked_Bar_Chart_User_Satisfaction.py
1 parent 5fba7ce commit 63273ea

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pandas as pd
2+
import matplotlib.pyplot as plt
3+
4+
5+
data = pd.read_csv('PEmpirical4.csv')
6+
7+
effectiveness_categories = [1, 2, 3, 4, 5]
8+
category_labels_effectiveness = {
9+
1: 'Not at all helpful',
10+
2: 'Slightly helpful',
11+
3: 'Moderately helpful',
12+
4: 'Very helpful',
13+
5: 'Extremely helpful'
14+
}
15+
data['Chat GPT effectiveness'] = pd.Categorical(data['Chat GPT effectiveness'], categories=effectiveness_categories, ordered=True)
16+
data['Chat GPT effectiveness'] = data['Chat GPT effectiveness'].map(category_labels_effectiveness)
17+
18+
satisfaction_categories = [1, 2, 3, 4, 5] # Presuming these are coded similarly in your data
19+
category_labels_satisfaction = {
20+
1: 'Very Dissatisfied',
21+
2: 'Somewhat Dissatisfied',
22+
3: 'Neutral',
23+
4: 'Somewhat Satisfied',
24+
5: 'Very Satisfied'
25+
}
26+
data['User satisfaction'] = pd.Categorical(data['User satisfaction'], categories=satisfaction_categories, ordered=True)
27+
data['User satisfaction'] = data['User satisfaction'].map(category_labels_satisfaction)
28+
29+
pivot_data = data.pivot_table(index='Chat GPT effectiveness', columns='User satisfaction', aggfunc='size', fill_value=0)
30+
31+
colors = ['salmon', 'steelblue', 'skyblue', 'plum', 'cornflowerblue']
32+
pivot_data.plot(kind='bar', stacked=True, figsize=(10, 6), color=colors)
33+
plt.title('Stacked Bar Chart of User Satisfaction by Chat GPT Effectiveness')
34+
plt.xlabel('Chat GPT Effectiveness')
35+
plt.ylabel('Count of Responses')
36+
plt.xticks(rotation=0)
37+
plt.legend(title='User Satisfaction', loc='upper right')
38+
plt.savefig('Stacked_Bar_Chart_User_Satisfaction.png', dpi=300, bbox_inches='tight')
39+
plt.show()

0 commit comments

Comments
 (0)