0

I am using matplotlib animation to graph the location of the inner planets relative to the sun for the past year. For the data I am using SPICE to create a point for the position each day, stored in an x and y array (365 values each).

This is my code to create the animation:

fig = plt.figure()
ax = plt.axes(xlim=[-4*10**8, 4*10**8], ylim=[-4*10**8, 4*10**8])

scat = ax.scatter([0, xMercuryLoc[0], xVenusLoc[0], xEarthLoc[0], xMarsLoc[0]], [0, yMercuryLoc[0], yVenusLoc[0], yEarthLoc[0], yMarsLoc[0]])

def animate(i):
    y_i = [0, yMercuryLoc[i], yVenusLoc[i], yEarthLoc[i], yMarsLoc[i]]
    x_i = [0, xMercuryLoc[i], xVenusLoc[i], xEarthLoc[i], xMarsLoc[i]]
    scat.set_offsets(np.c_[x_i, y_i])
    return scat
    
anim = FuncAnimation(fig, animate, interval=10, frames=365)
anim.save('output.gif')

Also, changing the interval does not seem to have much of an effect.

Any help would be appreciated!

EDIT: Here are the first 10 data points for Earth x and y points.

x = [23343320.639060527, 24632298.74279799, 25919329.017484125, 27204312.6323643, 28487150.25457559, 29767741.99434545, 31045987.34974221, 32321785.155013725, 33595033.53809597, 34865629.89440075]

y = [145740807.32299614, 145526071.4779142, 145300098.56522143, 145062901.54199225, 144814494.05692068, 144554890.5087885, 144284106.12172952, 144002157.04035965, 143709060.4470579, 143404834.70221475]
Holden
  • 632
  • 4
  • 15

0 Answers0