Advertisement
Guest User

log hist

a guest
Feb 11th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. # Plotting constants
  5. LB = -17
  6. UB = -5
  7. DIVISIONS = abs(UB - LB) * 2
  8. BER_LIMIT = 1E-9
  9.  
  10. def load(fname, column):
  11.     """Extracts a column from a CSV file as a NumPy array"""
  12.     arr = np.genfromtxt(fname, dtype='float32',
  13.                         skip_header=1, usecols=column, delimiter=",")
  14.     return arr
  15.  
  16. def ber_histogram(data):
  17.     """Plots a histogram of from NumPy array"""
  18.     fig = plt.figure(figsize=(6.5, 4.5))
  19.     ax = plt.subplot(111)
  20.     bins = [10 ** x for x in np.linspace(LB, UB, num=DIVISIONS)]
  21.     ax.hist(data, bins=bins)
  22.     plt.xscale('log')
  23.     plt.show()
  24.     plt.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement