0

i tried to plot a function that depends on other variables other than the main variable to see the difference and get the best resume but at the end the plot didn't show any graphs here's my code:

import matplotlib.pyplot as plt
import math as m


l=[(0,0.016699),(1,0.023958),(2,0.02724),(3,0.033468),(4,0.42456),(5,0.059325),(6,0.063399),(7,0.079788),(8,0.095916),(9,0.125),(10,0.14622),(11,0.20257),(12,0.21643),(13,0.28974),(14,0.4424),(15,0.55856),(16,0.59991),(17,0.72561),(18,0.9964),(19,1.6748),(20,1.69)]

for i in range (12000):
    t=i
    for j in l:
        a=j[0]
        c=j[1]
        v=m.sqrt((2*(150-(40*9.8*m.sin(m.radians(a)))))/(1.2*c*0.875))*m.tanh(m.sqrt(((150/40)-9.8*m.sin(m.radians(a)))*(1.2*c*0.875*0.0125))*t)
plt.plot(t,v)
plt.show()

and here's the output : enter image description here

i changed the x and y so the x took the place of y and the same for y so the picture is before the changes but the same result and that's not the main problem, also i tried to change the '12000' to just 100 to make the compiling time faster but no result

2
  • try plt.scatter(t,v) but you only have a single point as far as I can tell Commented Mar 2, 2022 at 0:44
  • t=11999, v=4.237005569029153. You have one point, and a line plot requires two or more points. Commented Mar 2, 2022 at 0:44

1 Answer 1

1

you are plotting only one dot : record your produced data into a list and plot the list:

l=[(0,0.016699),(1,0.023958),(2,0.02724),(3,0.033468),(4,0.42456),(5,0.059325),(6,0.063399),(7,0.079788),(8,0.095916),(9,0.125),(10,0.14622),(11,0.20257),(12,0.21643),(13,0.28974),(14,0.4424),(15,0.55856),(16,0.59991),(17,0.72561),(18,0.9964),(19,1.6748),(20,1.69)]
data_t = []
data_v = []
for t in range (50):
    for j in l:
        a = j[0]
        c = j[1]
        v = m.sqrt((2*(150-(40*9.8*m.sin(m.radians(a)))))/(1.2*c*0.875))*m.tanh(m.sqrt(((150/40)-9.8*m.sin(m.radians(a)))*(1.2*c*0.875*0.0125))*t)
        data_t.append(t)
        data_v.append(v)
print(data_v)
plt.plot(data_t,data_v)
plt.show()

output :

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.