How to get a graph to start a certain point? (matplotlib)
<p>I was just wondering if anyone could tell me how to start a graph at a certain height on the y axis? <a href="https://i.stack.imgur.com/qD217.png" rel="nofollow"><img src="https://i.stack.imgur.com/qD217.png" alt="enter image description here"></a></p>

<p>Like if I wanted to start my curve at 50? I am plotting the trajectories of projectiles and I need to be able to plot it when they enter a starting height that isn't 0. Thanks in advance! I am very new to python and matplotlib.</p>

<p>My Code for firing at an angle:</p>

<p>def angle_calculation():</p>

<pre><code>print("\nTo calculate the components of a projectile fired at an angle")
print("We need the angle(degrees), the initial velocity(ms-1), and")
print("The gravity constant (9.81 on earth)\n")
angle_0 = float(input("Please enter the angle you want it to be fired at: "))
angle_0 = (angle_0)/180.0*np.pi
speed = float(input("\nPlease enter the initial velocity you want it to be fire at\n In metres per second: "))
g=9.81
plt.figure()
time_max = ((2 * speed) * np.sin(angle_0)) / g
time = time_max*np.linspace(0,1,100)[:,None]
x_values = ((speed * time) * np.cos(angle_0))
y_values = ((speed * time) * np.sin(angle_0)) - ((0.5 * g) * (time ** 2)) 
distance_x = (speed * np.cos(angle_0))*time_max 
plt.plot(x_values,y_values, linewidth = 1.5)
plt.ylim([0,200])
plt.xlim([0,distance_x])
plt.show()   
print("")
print ("The Range of this projectile will be, "(distance_x))
print ("")
for x, y in zip(y_values, x_values):
    if x == 0 or y == 0:
        print(x, y)
return
</code></pre>

<p>Is it what you're looking for? </p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt

print("\nTo calculate the components of a projectile fired at an angle")
print("We need the angle(degrees), the initial velocity(ms-1), and")
print("The gravity constant (9.81 on earth)\n")
angle_0 = float(input("Please enter the angle you want it to be fired at: "))
angle_0 = (angle_0)/180.0*np.pi
speed = float(input("\nPlease enter the initial velocity you want it to be fire at\n In metres per second: "))
start = float(input("\nPlease enter the starting point\n In metres: "))
g=9.81
plt.figure()
time_max = ((2 * speed) * np.sin(angle_0)) / g
time = time_max*np.linspace(0,1,100)[:,None]
x_values = ((speed * time) * np.cos(angle_0))
y_values = ((speed * time) * np.sin(angle_0)) - ((0.5 * g) * (time ** 2))
x_values_trimmed = x_values[x_values&gt;start]
start_idx = np.where(x_values == x_values_trimmed[0])[0]
y_values_trimmed = y_values[int(start_idx):]
distance_x = (speed * np.cos(angle_0))*time_max 
plt.plot(x_values_trimmed,y_values_trimmed, linewidth = 1.5)
plt.ylim([0,200])
plt.xlim([start,distance_x])
plt.show()   
print("")
print ("The Range of this projectile will be, "(distance_x))
print ("")
for x, y in zip(y_values, x_values):
    if x == 0 or y == 0:
        print(x, y)

plt.show()
</code></pre>

<p>result:</p>

<pre><code>To calculate the components of a projectile fired at an angle
We need the angle(degrees), the initial velocity(ms-1), and
The gravity constant (9.81 on earth)

Please enter the angle you want it to be fired at: 50

Please enter the initial velocity you want it to be fire at
 In metres per second: 30

Please enter the starting point
 In metres: 20
</code></pre>

<p><a href="https://i.stack.imgur.com/BIRxd.png" rel="nofollow"><img src="https://i.stack.imgur.com/BIRxd.png" alt="enter image description here"></a></p>

python matplotlib