Skip to content

Instantly share code, notes, and snippets.

@tommyct614
Last active January 3, 2018 13:33
Show Gist options
  • Save tommyct614/3c3fa0479a9da926cf3db7e7b3e3e979 to your computer and use it in GitHub Desktop.
Save tommyct614/3c3fa0479a9da926cf3db7e7b3e3e979 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
xmin = 0 #xmin and xmax can be changed for different intervals
xmax = 2*(np.pi) #np.pi is the value of pi in numpy
N = 201
x = np.linspace(xmin,xmax,N)
y = np.zeros(len(x))
x2 = np.linspace(xmin,xmax,N)
y2 = np.zeros(len(x2))
for i in range(len(x)):
y[i] = np.sin(x[i])
for b in range(len(x2)):
y2[b] = np.cos(x2[b])
plt.plot(x,y,label="Sine")
plt.plot(x2,y2,label="Cos")
plt.xlabel("Angle in radians")
plt.ylabel("Sine/Cos")
plt.legend(loc=1)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment