3

In ipython notebook, I am using matplotlib.pyplot imshow in a for loop like this:

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

Basically I hope to show each image followed by a print out sentence. But what I get is 3 sentences are printed out together, then followed with 3 images.

I tried to use time.sleep(1) before print() but does not work. Any idea to get the outputs of plt.imshow() and print() interleaving with each other?

wakeupbuddy
  • 971
  • 1
  • 8
  • 17
  • This thread may help you http://stackoverflow.com/questions/6686550/how-to-animate-a-time-ordered-sequence-of-matplotlib-plots – Saif Charaniya May 20 '16 at 03:52

1 Answers1

1

Not what you asked for, but it will serve the same purpose:

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

Jupyter notebook showing images with titles

Neapolitan
  • 2,101
  • 9
  • 21