Jul-10-2020, 12:59 PM
Hi everybody,
When I was plotting according to the code below, it gives the result between -60 and 20 on the x-axis but I want only the part between -3 and 3.
I tried
ax = plt.gca()
ax.set_ylim([-3,3])
ax.set_xlim([-3,3])
However, this doesn't show after when the plot comes out from the boundaries but I want all the parts between -3 and 3.
Please help me guys
When I was plotting according to the code below, it gives the result between -60 and 20 on the x-axis but I want only the part between -3 and 3.
I tried
ax = plt.gca()
ax.set_ylim([-3,3])
ax.set_xlim([-3,3])
However, this doesn't show after when the plot comes out from the boundaries but I want all the parts between -3 and 3.
Please help me guys
import numpy as np import matplotlib.pyplot as plt from sympy import * import sympy as sp from scipy import integrate def f(t,r): theta,x,z=r ftheta=(-1/2)*(np.cos(x)*np.cos(z)+np.sin(theta)/100) fx=0.5*np.sin(theta)-(1/2)*np.cos(x)*np.sin(z) fz=0.5*np.cos(theta)+(1/2)*np.sin(x)*np.cos(z) return ftheta,fx, fz sol=integrate.solve_ivp(f,(0,2000),(np.pi/4,-np.pi/2,-np.pi/2), t_eval=np.linspace(0,2000,100000)) theta,x,z=sol.y plt.plot(x,z,color="red") plt.axis("scaled") plt.xlabel("x") plt.ylabel("z") plt.show()