python - PyCharm无法显示动画

标签 python animation matplotlib pycharm

我正在尝试使用包 matplotlib.animation 在 PyCharm 中绘制动画。但是,PyCharm 仅以 PNG 图形显示动画的第一帧。

动画是关于一个移动的矩形,python版本是2.7.14,代码在这里:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib import animation

x = [0, 1, 2]
y = [0, 1, 2]
yaw = [0.0, 0.5, 1.3]
fig = plt.figure()
plt.axis('equal')
plt.grid()
ax = fig.add_subplot(111)
ax.set_xlim(-10, 10)
ax.set_ylim(-10, 10)

patch = patches.Rectangle((0, 0), 0, 0, fc='y')

def init():
    ax.add_patch(patch)
    return patch,

def animate(i):
    patch.set_width(1.2)
    patch.set_height(1.0)
    patch.set_xy([x[i], y[i]])
    patch._angle = -np.rad2deg(yaw[i])
    return patch,

anim = animation.FuncAnimation(fig, animate,
                               init_func=init,
                               frames=len(x),
                               interval=500,
                               blit=True)
plt.show()

它在终端中运行良好,所以我认为PyCharm有问题。那我能做什么呢?

最佳答案

不幸的是,PyCharm 中的科学 View 无法处理动画。您必须在设置 | 中禁用绘图集成。工具| Python 科学 |在工具窗口中显示绘图。 PyCharm bug tracker 中的相应票证:PY-27233 .

关于python - PyCharm无法显示动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49963666/

相关文章:

Java Sprite 动画 - 似乎无法让我的 Sprite 正确重绘

android - Activity 没有传入的过渡动画

c - 在 ELF 可执行文件中检索 RELA 的符号名称

python - 如何使用 Matplotlib (Python 2.7) 和您自己的数据创建烛台图表

python - 使用conda升级到python 3.8

python - Django 中的 self 验证链接

python - 将预先存在的 django git 存储库部署到 heroku

python - CMake:安装配置时尚未创建的文件

c# - 使用 For 循环滑动对象 (C#)

Python 在终端中保存 PNG 与 IPython Notebook