I am using matplotlib with interactive mode on and am performing a computation, say an optimization with many steps where I plot the intermediate results at each step for debugging purposes. These plots often fill the screen and overlap to a large extent.

My problem is that during the calculation, figures that are partially or fully occluded don't refresh when I click on them. They are just a blank grey. 

I would like to force a redraw if necessary when I click on a figure, otherwise it is not useful to display it. Currently, I insert pdb.set\_trace()'s in the code so I can stop and click on all the figures to see what is going on

Is there a way to force matplotlib to redraw a figure whenever it gains mouse focus or is resized, even while it is busy doing something else?