from __future__ import division
import scipy, math
import matplotlib.pyplot as plt
# Graphing helper function
def setup_graph(title='', x_label='', y_label='', fig_size=None):
fig = plt.figure()
if fig_size != None:
fig.set_size_inches(fig_size[0], fig_size[1])
ax = fig.add_subplot(111)
ax.set_title(title)
ax.set_xlabel(x_label)
ax.set_ylabel(y_label)
freq = 1 #hz - cycles per second
amplitude = 3
time_to_plot = 2 # second
sample_rate = 100 # samples per second
num_samples = sample_rate * time_to_plot
t = scipy.linspace(0, time_to_plot, num_samples)
signal = [amplitude * math.sin(freq * i * 2*math.pi) for i in t] # Explain the 2*pi
setup_graph(x_label='time (in seconds)', y_label='amplitude', title='time domain')
plot(t, signal)
[<matplotlib.lines.Line2D at 0x3edc610>]