def draw_if_interactive():
figManager =  Gcf.get_active()<EOL>if figManager is not None:<EOL><INDENT>figManager.canvas.invalidate()<EOL><DEDENT>
For performance reasons, we don't want to redraw the figure after
each draw command. Instead, we mark the figure as invalid, so that
it will be redrawn as soon as the event loop resumes via PyOS_InputHook.
This function should be called after each draw event, even if
matplotlib is not running interactively.