I have a code in python to represent the energy decay in a damped oscilator, it reads like this:
def E(wt, Q):
return (np.e**(-x/Q))*(1-(1/2*Q)*np.sin(2*x))
x = np.linspace(0,20,1000)
y0 = E(x,2)
y1 = E(x,4)
y2 = E(x,8)
y3 = E(x,16)
plt.plot(x, y0, 'p', label=r'$Q=2$')
plt.plot(x, y1, 'r', label=r'$Q=4$')
plt.plot(x, y2, 'g', label=r'$Q=8$')
plt.plot(x, y3, 'b', label=r'$Q=16$')
plt.xlabel(r'$wt$')
plt.ylabel(r'$E$')
plt.title (r"$E(t) -vs.- wt$")
plt.show()
yet it should look like this: https://www.dropbox.com/s/o2mmmi8v6kdnn2v/good_graph.png?dl=0 what am I doing wrong? I have the right function
Fixed Equation
Your original equation
Errors
wt
(1/2*Q)
when you mean(1/2/Q)
(1/2./float(Q))
p
inplt.plot(x, y0, 'p', label=r'$Q=2$')
butp
creates the strange point plot behaviour. To fix this pass in the color names explicitly e.g.plt.plot(x, y0, color='purple', label=r'$Q=2$')
Off Topic
To make your title nicer:
Full Code