-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmake_plots.py
executable file
·75 lines (51 loc) · 1.61 KB
/
make_plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
#
# A simple script that makes use of Seaborn to create a set of
# interesting plots to analyse the reviews. Please note that I
# hard-coded everything for ICLR 2020 for now.
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style("dark")
df = pd.read_csv('2020.csv', index_col='review_id')
df['experience'] = df['experience'].astype('int')
df['experience'] = df['experience'].astype('category')
df['rating'] = df.rating.astype('category')
plt.figure(figsize=(8, 5))
ax = sns.distplot(df['n_words'], kde=False)
ax.set_xlabel('Number of words')
ax.set_ylabel('Count')
plt.tight_layout()
plt.savefig('ICLR_2020_histogram_words.svg')
plt.figure(figsize=(4, 5))
ax = sns.boxplot(x=df['rating'], y=df['n_words'], data=df)
ax.set_xlabel('Rating')
ax.set_ylabel('Number of words')
plt.tight_layout()
plt.savefig('ICLR_2020_boxplots_01.svg')
plt.clf()
ax = sns.boxplot(x=df['experience'], y=df['n_words'], data=df)
ax.set_xlabel('Experience')
ax.set_ylabel('Number of words')
plt.tight_layout()
plt.savefig('ICLR_2020_boxplots_02.svg')
plt.clf()
g = sns.catplot(
x='rating',
y='n_words',
col='experience',
kind='box',
data=df,
aspect=0.6
)
g.set_axis_labels('Rating', 'Number of words')
g.set_titles('Experience = {col_name}')
plt.tight_layout()
plt.savefig('ICLR_2020_boxplots_03.svg')
plt.clf()
g = sns.FacetGrid(data=df, col='experience', hue='rating')
g = g.map(sns.countplot, 'rating', order=sorted(df['rating'].unique()))
g.set_axis_labels('Rating')
g.set_titles('Experience = {col_name}')
plt.tight_layout()
plt.savefig('ICLR_2020_countplot.svg')