简体   繁体   English

如何制作电影(相对于Matlab)?

[英]How to create a movie (in relation to matlab)?

I have this code in matlab (in one function): 我在matlab中有以下代码(在一个函数中):

...
m = size(myList, 3);
for k = 1:m
    g = myList(:, :, k);
    image(g + 1)
    axis off
    axis square
    M(k) = getframe;
end;

and in another file (another function): 并在另一个文件中(另一个功能):

...
M = showGraphs(grids)
movie(M, 1)

I want to do the movie in matplotlib. 我想在matplotlib中做电影。 Until now, I did (for the first piece of code): 到目前为止,我还是(对于第一段代码):

m=sc.shape(myList,3)
for k in range(m):
    g=myList[:,:,k]
    plt.axis("False")
    plt.imshow(g+1) -->> i don't know if it's right

I don't know what to do with M(k)=getframe and then with movie(M,1) . 我不知道先用M(k)=getframe然后再用movie(M,1)

How can I proceed? 我该如何进行? because I'm confused about the way in matplotlib. 因为我对matplotlib中的方法感到困惑。

----UPDATED------------------------------ - - 更新 - - - - - - - - - - - - - - -

I did: 我做了:

 n=sc.shape(data)[2]
    ims=[]
    for i in range(n):
        mydata=data[:,:,i]
        im=plt.imshow(mydata,cmap=plt.get_cmap('jet'))
        ims.append([im])
    return ims

and then : 接着 :

fig=plt.gcf()
ani=ArtistAnimation(fig,result,interval=10,repeat=False)

有很多不同的方式,请参见以下动画示例: http : //matplotlib.sourceforge.net/examples/animation/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM