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 循環(huán)內(nèi)的打印語(yǔ)句顯示狀態(tài),但是 animate 函數(shù)內(nèi)的打印語(yǔ)句沒(méi)有顯示任何內(nèi)容,這意味著該函數(shù)沒(méi)有被調(diào)用。我找不到任何邏輯錯(cuò)誤。請(qǐng)幫忙。
添加回答
舉報(bào)
0/150
提交
取消