Создание симулятора орбиты между Землей и Марсом.Как вы можете видеть из приведенного ниже кода, я использую функцию _update_plot, которую я на 60% понимаю, как ее использовать.
Если я хочу, чтобы линия, идущая от Земли, пересекала Марс и переходила в статический фон, как бы я могла это сделать?сделать это?
#imports
import math
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
from matplotlib.widgets import Slider, Button, RadioButtons
#style choices
plt.rcParams["figure.figsize"] = [15.6, 13.0]
def _update_plot(i, fig, scat):
scat.set_offsets(([math.cos(math.radians(i))*5, math.sin(math.radians(i))*5], [math.cos(math.radians(i/2))*10, math.sin(math.radians(i/2))*10], [0, 0]))
print('Frames: %d' %i)
return scat
fig = plt.figure()
x = [0]
y = [0]
ax = fig.add_subplot(111)
ax.grid(True, linestyle = '-', color = '0.10')
ax.set_xlim([-50, 50])
ax.set_ylim([-50, 50])
scat = plt.scatter(x, y, c = x)
scat.set_alpha(0.8)
anim = animation.FuncAnimation(fig, _update_plot, fargs = (fig, scat),
frames = 720, interval = 10)
plt.show()