I am trying to model an orbit using a 4th order Runge-Kutta method, which works and gives a good numerical output. My issue is that when I try and plot the orbit around a fixed point, I can only see it if I specify that each data point is a point. This code is below:
T, X, Y, V_X, V_Y = orbit(x, y, v_x, v_y)
results = [(X, Y)]
results = np.array(results) #converts the results list to an array that can be called upon for the values of x and y for the graph
X = results[:,0] #gets values for x for graph
Y = results[:,1] #gets values for y for graph
pp.axis('equal')
pp.plot(X, Y, 'o') #plots graph of above X and Y with circular points connected by a line.
pp.scatter(0,0, s=1000, color='g')
pp.show()
This gives an output of:
when I get rid of the 'o' in the pp.plot line, the line vanishes. My only thought is that the thickness is very narrow compared to the scales on the graph, but I have never had this issue before.
1 Answer 1
Test only this:
T, X, Y, V_X, V_Y = orbit(x, y, v_x, v_y)
pp.axis('equal')
pp.plot(X, Y) #plots graph of above X and Y with circular points connected by a line.
pp.scatter(0,0, s=1000, color='g')
pp.show()
1 Comment
Explore related questions
See similar questions with these tags.
XandY?resultsis not a simple array. Might be an array of tuples... Can you show whatresultslooks like?