|
发表于 2021-9-25 11:36:07
|
显示全部楼层
本帖最后由 suchocolate 于 2021-9-25 11:42 编辑
普通方式:- import matplotlib.pyplot as plt
- x = [9, 12]
- y = [90, 93]
- fig, ax = plt.subplots()
- ax.scatter(x, y, c='r', marker='o')
- plt.show()
复制代码
动画方式:- import matplotlib.pyplot as plt
- import matplotlib.animation as animation
- def init():
- ax.set_xlim(0, 20)
- ax.set_ylim(0, 100)
- return ax,
- def run(data):
- x, y = data
- ax.scatter(x, y, c='r', marker='o')
- return ax,
- fig, ax = plt.subplots()
- data = [[9, 90], [12, 93]]
- ani = animation.FuncAnimation(fig=fig, func=run, frames=data, interval=2000, init_func=init)
- plt.show()
复制代码 |
|