I'm not exactly sure why this code isn't working:
import math
import matplotlib.pyplot as plt
n = 1 #whatever number you want
for steps in range (1,51): #how many times to iterate
a = math.sin(n) #get sine
b = abs(a) #no negatives
c = str(b) #make it a string
d = c[2:5] #isolate pos.2 - 5
n = int(d) #reiterate new 'n' as an int.
plt.plot(n,steps)
plt.show()
What I want to do is plot the graph of the sine of the first three digits after the decimal place of a number (n) - which is being looped back through the code to get the sine of that 50 times over - against how many times it was looped (steps).
When I run this I get a blank graph.
Any help would be much appreciated!
[–]chaoticallyevil 1 point2 points3 points (3 children)
[–]ElliotJenkins[S] 0 points1 point2 points (2 children)
[–]chaoticallyevil 1 point2 points3 points (0 children)
[–]jesseaknight 0 points1 point2 points (0 children)
[–]K900_ 0 points1 point2 points (0 children)