-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhist.py
31 lines (25 loc) · 897 Bytes
/
hist.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
#!/bin/python
# Joshua Skootsky, June 2, 2015
# Usage: python hist.py name-of-output-file (from erdos-renyi graph simulation)
from __future__ import (absolute_import, division, print_function)
import numpy as np
import matplotlib.pyplot as plt
from StringIO import StringIO
import math
import seaborn as sns
import os
from sys import argv
filename = argv[1]
with open(filename, 'r') as f:
data = f.read()
#Automatically closes when block ends
voltages = np.genfromtxt(fname=StringIO(data),dtype='float', delimiter='\n', comments='#')
# get comments
with open(filename, 'r') as f:
first_line = f.readline()
# Histogram the voltages
plt.hist(voltages, bins=100, normed=True)
plt.title("Normalized Voltage Distribution of " + filename + "\n" + first_line, fontsize=14, horizontalalignment='center')
plt.xlabel("Voltage", fontsize=14)
plt.ylabel("Probability", fontsize=14)
plt.show()