1. 问题:绘制图自动转化为png
或者显示空白
2. 解决过程
2.1. 打开设置
2.2. 取消勾选
在tool里找到plot,或者直接搜索,取消勾选Show plots in tool Windows
3. 最后成功显示
不再是侧面的工具栏,而是单独形成一个窗口
4.代码
代码借鉴官网:
Animated scatter saved as GIF — Matplotlib 3.10.0 documentation
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
fig, ax = plt.subplots()
ax.set_xlim([0, 10])
scat = ax.scatter(1, 0)
x = np.linspace(0, 10)
def animate(i):
scat.set_offsets((x[i], 0))
return (scat,)
ani = animation.FuncAnimation(fig, animate, repeat=True, frames=len(x) - 1, interval=50)
# To save the animation using Pillow as a gif
writer = animation.PillowWriter(fps=15,
metadata=dict(artist='Me'),
bitrate=1800)
ani.save('scatter.gif', writer=writer)
plt.show()
标签:plt,动图,writer,matplotlib,animation,import,pycharm,scatter From: https://blog.csdn.net/m0_47171044/article/details/145143831