Update some part of a figure


I’ve poste here a question but no one seems to have an hint to give so I repeat my question here.

In the attached Python 3 code, I draw n**2 squares in black and then I dynamically change in a random way the colors of some squares.

The problem I met is that at each new random choice, I redraw all the squares. I know that it is stupid for large number of squares.

Is there a way to change some propriety of one square, and then to ask to matplotlib to redraw only what have changed ? I’m looking for something similar to blint for animations.

Christophe BAL

tetrisDraft.py (1.5 KB)