为了账号安全,请及时绑定邮箱和手机立即绑定

我如何动态(循环)在 google colab 中显示图像?

我如何动态(循环)在 google colab 中显示图像?

慕慕森 2021-07-09 14:15:48
我一直在尝试使用 pyplot/matplotlib 来显示图像,因为它们在循环中发生变化,但我无法使任何工作正常进行。我基本上无法更新显示的图像。这是复制问题的代码:f = plt.figure(1)ax = plt.gca()show_obj= ax.imshow(np.random.randn(28,28))for i in range(10):  print(i)  # None of these 3 options work  if True:    # the image does not update    show_obj.set_data(np.random.randn(28,28))    f.canvas.draw()  if False:    # image does not update    ax.clear()    ax.imshow(np.random.rand(28,28))    pass  if False:    # starts drawing new axes    f = plt.figure(1)    ax = plt.gca()    ax.imshow(np.random.rand(28,28))  plt.show()
查看完整描述

3 回答

  • 3 回答
  • 0 关注
  • 260 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信