如何在Python中制作动画?

时间:2018-11-24 03:12:42

标签: python animation

我正在尝试通过称为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()

每次看到结果时,我只会得到下面的图像。 The image that I want to make it an animation

如果有人告诉我如何将其更改为动画,我将不胜感激。

0 个答案:

没有答案