title: Matplotlib - sequence is off when using plt.imshow()
body: <p>I write a dog-classifier in a Jupyter notebook that, every time a dog is detected in an image, should show the image and print some text describing it. Somehow, the images are always displayed after all the text was printed, no matter in which order I put <code>plt.imshow()</code> and <code>print()</code>. Does anybody know why this is the case?</p>
  
  <p>Thank you!</p>
  
  <p>Here is my code-snippet:</p>
  
  <pre><code>for i in range (0, 1,1):
  
      all_counter+=1
  
      if dog_detector(dog_files_short[i]):
  
          img = image.load_img(dog_files_short[i], target_size=(224, 224))
          plt.show()
          plt.imshow(img)
          time.sleep(5)
          print("That's a dog!!!!")
          dog_counter+=1
          print("______________")
  
      else: 
  
          print("______________")
          img = image.load_img(dog_files_short[i], target_size=(224, 224))
          plt.show()
          plt.imshow(img)
          print("No Doggo up here :(")
          print(ResNet50_predict_labels(dog_files_short[i]))
          print("______________")
  
  print((dog_counter/all_counter)*100, "% of the dog pictures are classified as dogs")
  </code></pre>
  
  <p>The output is like this:</p>
  
  <p><img src="https://i.stack.imgur.com/8Bj8w.png" alt="example output"></p>