import mathimport matplotlibimport matplotlib.pyplot as pltimport matplotlib.patches as patchesfrom matplotlib.patches import Circlefrom matplotlib import animationfrom utils import rgb2hexfrom tg import small_tgmatplotlib.rcParams["figure.figsize"]=(10, 5)matplotlib.rcParams['toolbar'] = 'None'fig, ax = plt.subplots()ax.axis("equal")ax.set_xlim(-10, 10)ax.set_ylim(-5, 5)ax.axis("off")state_nodes = []for state in small_tg["states"]: center = small_tg["states"][state]["graphic_properties"]["position"] state_nodes.append(Circle(center, 0.2, color = rgb2hex(255, 255, 255)))def animate(i, state): print("&", i ,state) y = math.ceil((abs(i-100))*2.55) print(i, y, (abs(i-100))*2.55) state.set_color = rgb2hex(y,y,y) ax.add_artist(state) return state,for state in state_nodes: print(state) animation.FuncAnimation(fig, animate, fargs = (state,), frames=201, interval=1, blit=True, repeat = False)plt.show()for 循环内的打印语句显示状态,但是 animate 函数内的打印语句没有显示任何内容,这意味着该函数没有被调用。我找不到任何逻辑错误。请帮忙。
添加回答
举报
0/150
提交
取消