I'm using python to generate an animation of an orbit. However, for a given type of orbit, the trajectory should "collide" with the planet and not overlap its image (pictured below). How can I put the planet image (grey circle) over the trajectory animation (yellow)?
fig = plt.figure()
plt.xlabel("x (km)")
plt.ylabel("y (km)")
plt.gca().set_aspect('equal')
ax = plt.axes()
circle = Circle((0, 0), 2, color='dimgrey')
plt.gca().add_patch(circle)
ax.set_facecolor("black")
plt.axis([-1 / u1 , 1 / u1 , -1 / u1 , 1 / u1 ])
graph, = plt.plot([], [], color="gold", markersize=3)
plt.close()
def animate(i):
graph.set_data(x[:i], y[:i])
return graph,
ani = FuncAnimation(fig, animate, repeat=False, frames=len(x), interval=1)
HTML(ani.to_jshtml())
Draw it last. Each time you animate, try to draw the circle again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.