1

I recently learned Python and succesfully programmed Conway's game of life using numpy arrays. My problem is that I can't plot them. I can plot one array, but I don't know how to update the plot in the current matplotlib window as much as I want.

A funtion to calculate the next generation (takes a numpy array as argument and returns one too) and the start grid (numpy array) are given. I'm using Python 3.9.

I can't find a simple solution with a while loop that doesn't open a new window for every iteration. It shouldn't be that hard. Could anyone help me?

I have already found: Matplotlib: Animate 2D Array, but that doesn't work.

4
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Apr 20, 2023 at 23:52
  • 1
    It's unspecific. See How to Ask. Research more, try to implement a prototype and post a minimal reproducible example and debugging details. Anyway, see this question and this question. Commented Apr 23, 2023 at 10:15
  • I was having trouble accomplishing a similar task, so instead of displaying each frame as it's calculated (ie. 'realtime'), I precompute and store them. Then I use an ipympl widget to scroll through the buffer like a video. I'll post my code if that sounds helpful. Commented May 4, 2023 at 17:27
  • Do you really need to use matplotlib for this? I think that pygame is a lot better suited for this problem. Commented Aug 27, 2023 at 16:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.