Я бы хотел менять цвет круга каждые 0,25 секунды в потоке и показывать результат в режиме анимации matplotlib
.Вот мой код (я даже не понимаю, почему анимация не выполняется):
import threading
import time
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
from matplotlib.animation import FuncAnimation
def apply_color_shift(fig, circle):
def func():
for i in range(100):
circle.set_fc((i/100, 0, 0, 1))
time.sleep(0.25)
print("something")
anim = threading.Thread(target = func)
def do_nothing(frame):
print("ANIM")
fig.show()
FuncAnimation(fig, do_nothing, frames = [0.1*i for i in range(100)])
anim.start()
plt.show()
fig, ax = plt.subplots()
ax.axis('square')
c = Circle(xy = (0, 0), color = "red")
ax.add_patch(c)
ax.set_xlim([-50, 50])
ax.set_ylim([-50, 50])
fig.show()
apply_color_shift(fig, c)
В чем здесь проблема и как ее решить?