python - 如何在 Python 中制作动画?
问题描述
我正在尝试使用称为 X 门的量子计算创建有关一个量子位的 x、y、z 坐标变化的动画。这是我写的代码。
#length means number of phase here
length = 10
# theta, pi are variable we need to calculate x,y,z in each phase
# and I get these values from users.
xgate_theta = np.linspace(theta,theta+np.pi,length)
xgate_phi = np.linspace(phi,phi,length)
# this array contains all the coordinates in each phase
xgate= []
# these array contains only one kind of coordinates
xgate_x = []
xgate_y = []
xgate_z = []
for i in range(length):
# X means x coordinate in the initial phase
xgate_x.append(X)
xgate_z.append(np.cos(xgate_theta[i]))
xgate_y.append(np.sqrt(1-np.sqrt(xgate_x[i]**2+xgate_z[i]**2))*(-1))
for j in range(length): xgate.append(put.quiver(0,0,0,xgate_x[j],xgate_y[j],xgate_z[j],color="red")
# I don't show you the codes for fig, but it doesn't have any problems
ani = animation.ArtistAnimation(fig,xgate,interval=1000)
plt.show()
如果有人告诉我如何将其更改为动画,我将不胜感激。
解决方案
推荐阅读
- sql-server - 需要在大型数据集中生成缺少数据的行 - SQL
- python - 'NoneType' 类型的 for 循环参数不可迭代
- java - 无法在我的 Java 应用程序中使用自定义 checkstyle.xml
- arrays - 如果,其他功能不起作用 - 石头、剪子、石头游戏 javascript
- javascript - 如何正确地并发 javascript 异步承诺?
- html - 将 URL 参数传递给表单输入,而不在表单发布后重置
- sql - 使用前几行中的值更新表,然后在下一次计算中使用输出值
- javascript - 我如何像在 concat() 中那样将多个值传递给函数?
- java - 增加Tomcat关闭超时
- r - GAMs 空间分析 (mgcv) - 添加地图进行可视化