Edit: I realized now that 180 degrees is wrong, it should have been from 0-90 degrees, so edited that. sorry.
First time asking a question on Stackoverflow so I'm so sorry if I've done anything wrong.
Usually I try to google my way to my answers but this time I have absolutely zero clue, and the only place where it looks like I could find a similar task was on wired, but the links does not work unfortunately.
My problem: I'm attempting to show in a graph what angle is the best angle to throw at in order to make the ball travel the furthest. So far I have been able to draw all possible outcomes when thrown at any angle between 0 and 90. However this looks really messy, how can I make it so that the furthest distance on the x axis is "highlighted".
I do know that 45 degrees is the best angle, and I guess I could just hardcode it in, but is there another (simple) way to show it?
See the link further down for the results i get with my current code.
My code:
import matplotlib.pyplot as plt
x0 = 0.0 # Startposition on x-axis
y0 = 0.0 # Startposition on y-axis
v0 = 10.0 # Startvelocity
g = 9.81 # Gravity
dt = 0.01 # Time resolution (number of seconds per time step)
N = 200 # Amount of time steps
th0 = 0.0 # The angle the ball is thrown at
# Calculations
x = np.zeros((1, N))
y = np.zeros((1, N))
# I begin with this as i want to test all angles between 0 (horizontal) and up to 90(straight up)
for th0 in range(90):
for k in range(N):
x[0,k] = x0 + v0*np.cos(th0*np.pi/180.0)*dt*k # motion equation on x-axis. No acceleration
y[0,k] = y0 + v0*np.sin(th0*np.pi/180.0)*dt*k - 0.5*g*(dt*k)*(dt*k) # motion equation on y-axis. gravity acceleration.
plt.plot(x[0,:], y[0,:])
plt.plot([0,12],[0,0])
th0=th0+1
plt.grid()
plt.axis([0, 12, 0, 12])
plt.show()
As u can see in the image linked below, everything is kinda messy, i wish i could highlight the line at which the ball travels the furthest and the angle it is thrown at.

Again sorry if my english is terrible or if ive done anything else the wrong way. I speed translated the code, so some of the comments may be a bit weird.
Edit2: I want it to look kind of like the picture below, just without the hardcoding, however i might have a solution, just due to my exams i dont have time to look more at it atm. If anyone ever comes across this and is wondering about the same let me know. If not i guess ill just close this (if thats even possible).

