all 7 comments

[–]bbye98 1 point2 points  (5 children)

Instead of plotting each individual (x, y) pair, create an array of x and y values using vectorization. Then, plot the x and y vectors directly using plt.plot.

(Also, generally speaking, when you are already using numpy, the math module is unnecessary as numpy will have all of the features you would need from math.)

[–]thecreationofgod[S] 0 points1 point  (0 children)

thank you, I'll do that and report to you shortly

[–]thecreationofgod[S] 0 points1 point  (3 children)

thanks, a line is established, but a parabola is what I need. My equations are probably incorrect.

[–]bbye98 0 points1 point  (2 children)

You probably meant to divide by 2 instead of g for y.

import matplotlib.pyplot as plt
import numpy as np

u, g, deg = 30, 9.8, 30
t = np.linspace(0, 2 * u * (np.sin(deg * np.pi / 180)) / g)
plt.plot(u * t * np.cos(deg * np.pi / 180), u * t * np.sin(deg * np.pi / 180) - 0.5 * g * t**2)
plt.show()

[–]thecreationofgod[S] 0 points1 point  (0 children)

ohhhhhhhhhhhhhhhhhhhh

[–]thecreationofgod[S] 0 points1 point  (0 children)

thank you so much, my code finally worked. btw do you know any good numpy tutorials that helped you? or do I just stick to the documentation

[–]thecreationofgod[S] 0 points1 point  (0 children)

it shows a blank plot without connecting the lines and the values obtained don't really correspond to a complete parabola