繁体   English   中英

如何将分散添加到 plt.imshow

[英]How add scatter to plt.imshow

我为动画图像编写代码,如何在其上添加点?
(代码在这种形式下不起作用,我已经尽可能简化了)

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

files = os.listdir(r'..')
fig = plt.figure()
myimages = []

for i in files:
    frame = np.load(r'..\{}'.format(i))
    cmap = plt.cm.jet
    image = cmap(norm(ndimage.grey_closing(frame)))

    plt.scatter(point_arr[:, 1], point_arr[:, 0])  # Wanna add this in anim

    frame1 = plt.imshow(image, cmap=cmap)
    myimages.append([frame1 ])

my_anim = animation.ArtistAnimation(fig, myimages, interval=50, blit=True, repeat_delay=2000)
plt.show() # show but without my point

没有动画所有的工作,但我不知道如何合并

frame1 = plt.imshow(frame2, cmap=cmap)
plt.scatter(point_arr[:, 1], point_arr[:, 0])
plt.show() # all work

工作

    plt.scatter(point_arr[:, 1], point_arr[:, 0], c='green')
    plt.imshow(image, cmap=plt.cm.jet)
    camera.snap()

animation = camera.animate(interval=50, blit=True, repeat_delay=2000)
animation.save('test.gif', writer='imagemagick')
print('End')

暂无
暂无

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

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