我有一些在 Spyder 中运行的代码,但是当我尝试在 Jupiter 笔记本中运行它时它不起作用(我已经尝试将 %matplot lib 放在单元格的顶部,但我只是收到以下错误: AttributeError: 'NoneType' 对象没有属性 'lower') 这是代码:
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import animation
def randrange(n, vmin, vmax):
return (vmax - vmin) * np.random.rand(n) + vmin
n = 100
xx = randrange(n, 23, 32)
yy = randrange(n, 0, 100)
zz = randrange(n, -50, -25)
fig = plt.figure()
ax = Axes3D(fig)
def init():
ax.scatter(xx, yy, zz, marker='o', s=20, c="goldenrod", alpha=0.6)
return fig,
def animate(i):
ax.view_init(elev=10., azim=i)
return fig,
# Animate
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=360, interval=20, blit=True)
有什么想法吗?
答案 0 :(得分:0)
Jupiter 环境不具备渲染动画的能力,所以好像使用了 HTML 视频功能。我是 jupyterLab,我总是用这个来运行。
{{1}}