forked from bernhardkaplan/bcpnn-mt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_matrix_as_histogram.py
executable file
·64 lines (51 loc) · 1.31 KB
/
plot_matrix_as_histogram.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
import numpy
import pylab
import sys
fn = sys.argv[1]
title = fn
n_bins = 1000
#d = numpy.loadtxt(fn, skiprows=1)
d = numpy.loadtxt(fn)
d_thresh = 1e-1
d_new = []
d = d.flatten()
#log_d = numpy.zeros(d.size)
#log_d = []
#for i in xrange(d.size):
# if d[i] > 0:
# log_d.append(numpy.log(d[i]))
# if abs(d[i]) > d_thresh:
# d_new.append(d[i])
#log_d = numpy.array(log_d)
# d_new
#d_new = numpy.array(d_new)
#fig = pylab.figure()
#x_max = d_new.max()
#bin_width = (d_new.max() - d_new.min()) / n_bins
#data, bins = numpy.histogram(d_new, n_bins)
#ax = fig.add_subplot(111)
#ax.bar(bins[:-1], data, width=bin_width)
#pylab.title("Bin width = %f" % (bin_width))
#pylab.ylabel("Count")
#pylab.title("w_thresh = %.1e" % d_thresh)
# log
#fig = pylab.figure()
#x_max = log_d.max()
#bin_width = (log_d.max() - log_d.min()) / n_bins
#data, bins = numpy.histogram(log_d, n_bins)
#ax = fig.add_subplot(111)
#ax.bar(bins[:-1], data, width=bin_width)
#pylab.title("Bin width = %f" % (bin_width))
#pylab.ylabel("Count")
#pylab.title("log(weights) (if w > 0)")
#pylab.show()
# d normal
fig = pylab.figure()
x_max = d.max()
bin_width = (d.max() - d.min()) / n_bins
data, bins = numpy.histogram(d, n_bins)
ax = fig.add_subplot(111)
ax.bar(bins[:-1], data, width=bin_width)
pylab.title(fn)
pylab.ylabel("Count")
pylab.show()