0

I have code that runs in a while loop and returns a new numpy array on every iteration. I would like to continuously render that array to an onscreen window.

Based on Displaying Numpy Matrix as Video, Is there a way to detach matplotlib plots so that the computation can continue?, How to update matplotlib's imshow() window interactively?, and real-time plotting in while loop with matplotlib, this is my best attempt:

import matplotlib.pyplot as plt
import numpy as np

# plt.ion()
image = np.zeros((800, 800))
im = plt.imshow(image)
while True:
    image += .01
    im.set_data(image)
    plt.pause(0.05)
plt.show()

It does not work (for some reason it just renders a purple square that does not change color). I am using ImageMagick on Ubuntu 16.04. Thank you for your assistance.

ethanabrooks
  • 747
  • 8
  • 19

1 Answers1

0

Simple correction:

image = np.zeros((800, 800, 3))

Now it works.

ethanabrooks
  • 747
  • 8
  • 19