forked from jbmouret/matplotlib_for_papers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_median.py
35 lines (28 loc) · 804 Bytes
/
plot_median.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
import glob
from pylab import *
def load(dir):
f_list = glob.glob(dir + '/*/*/bestfit.dat')
num_lines = sum(1 for line in open(f_list[0]))
i = 0;
data = np.zeros((len(f_list), num_lines))
for f in f_list:
data[i, :] = np.loadtxt(f)[:,1]
i += 1
return data
# compute the median of each column
def med(data):
median = np.zeros(data.shape[1])
for i in range(0, len(median)):
median[i] = np.median(data[:, i])
return median
data_low_mut = load('data/low_mut')
data_high_mut = load('data/high_mut')
# generate the x
n_generations = data_low_mut.shape[1]
x = np.arange(0, n_generations)
# compute the medians
med_low_mut = med(data_low_mut)
med_high_mut = med(data_high_mut)
plot(x, med_low_mut)
plot(x, med_high_mut)
savefig('medians1.png')