forked from justinbois/bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlesson23_24_ex.py
32 lines (27 loc) · 866 Bytes
/
lesson23_24_ex.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
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import seaborn as sns
rc = {'lines.linewidth' : 2, 'axes.labelsize' : 18,
'axes.titlesize' : 18}
sns.set(rc=rc)
def ecdf(data):
"""
Compute x, y values for an empirical distribution function.
"""
x = np.sort(data)
y = np.arange(1, 1+len(x)) / len(x)
return x, y
# Load data
xa_high = np.loadtxt('data/xa_high_food.csv',comments='#')
xa_low = np.loadtxt('data/xa_low_food.csv',comments='#')
x_high, y_high = ecdf(xa_high)
x_low, y_low = ecdf(xa_low)
plt.plot(x_high, y_high, marker='.', linestyle='none', markersize=20,
alpha=0.5)
plt.plot(x_low, y_low, marker='.', linestyle= 'none', markersize=20,
alpha=0.5)
plt.xlabel('Cross-sectional area ($\mu$m)')
plt.ylabel('eCDF')
plt.legend(('High Food', 'Low Food'), loc='lower right')
plt.show()