JGuizard
6/12/2016 - 3:50 PM

Draw a graph with matplotlib

Draw a graph with matplotlib

import sys
import numpy as np
import matplotlib.pyplot as plt

# Determine if we are requested to plot normal or uniform.
if len(sys.argv) != 2 or sys.argv[1] == 'normal':
    plt.title("Normal Random Numbers")
    x = np.random.randn(1000000)
else:
    plt.title("Uniform Random Numbers")
    x = np.random.rand(1000000)
print len(x)
plt.xlabel('Random Number')
plt.ylabel('Count')
plt.hist(x, 100)
plt.show()