使matplotlib imshow blocking print()在for循环中

2024-04-23 12:05:24 发布

您现在位置:Python中文网/ 问答频道 /正文

在ipython笔记本中,我使用matplotlib.pyplot在这样的for循环中显示:

for i in range(3):
    plt.figure()
    plt.imshow(I[i])
    print("some explanation for image " + str(i))

基本上,我希望在每个图片后面显示一个打印出来的句子。但我得到的是3个句子一起打印出来,然后是3张图片。在

我试着用时间。睡觉(1) 在print()之前,但不起作用。有没有办法得到plt.imshow公司()和print()相互交错?在


Tags: informatplotlibipython图片笔记本rangeplt