import numpy as np from tkinter import * from tkinter import messagebox from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt # 创建画布需要的库 from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
# 抛物线动态绘制函数 def drawImg(): global i i += 1 global ax #ax.clear() ax.set_xlim(0, 100) ax.set_ylim(0, 100) ax.set_zlim(0, 100) global x global y global z t = i * 0.1 dtax = 20 * t * np.sin(0.25 * np.pi) x.append(dtax) dtay = 20 * t * np.cos(0.25 * np.pi) y.append(dtay) dtaz = 100 - t ** 2 * 0.5 * 10 z.append(dtaz) ax.plot(x, y, z) canvas.draw() global afterHandler afterHandler = root.after(100, drawImg)