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
|
#!/usr/bin/env python
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import sys
if len(sys.argv) != 3:
print("Wrong number of arguments.")
print("USAGE: ./plot_histogram.py <input_file> <output_file>")
quit()
input_file = sys.argv[1]
output_file = sys.argv[2]
f = open(input_file)
X = [int(i) for i in f.readlines()]
X.sort()
# Y = {}
# for x in X:
# if x in Y:
# Y[x] = Y[x] + 1
# else:
# Y[x] = 1
#
# print(Y)
# the histogram of the data
n, bins, patches = plt.hist(X, max(X)-min(X)+1, facecolor='green')
# add a 'best fit' line
# y = mlab.normpdf( bins, mu, sigma)
# l = plt.plot(bins, y, 'r--', linewidth=1)
plt.xlabel('Sample Index')
plt.ylabel('Number of Selections')
# plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$')
# plt.axis([40, 160, 0, 0.03])
# TODO: adapt for different drum kits!
plt.xlim(0,97)
plt.grid(True)
plt.savefig(output_file)
|