@@ -146,6 +146,41 @@ def ion():
146146 'Turn interactive mode on.'
147147 matplotlib .interactive (True )
148148
149+ def pause (interval ):
150+ """
151+ Pause for *interval* seconds.
152+
153+ If there is an active figure it will be updated and displayed,
154+ and the gui event loop will run during the pause.
155+
156+ If there is no active figure, or if a non-interactive backend
157+ is in use, this executes time.sleep(interval).
158+
159+ This can be used for crude animation. For more complex
160+ animation, see :mod:`matplotlib.animation`.
161+
162+ """
163+ backend = rcParams ['backend' ]
164+ if backend in _interactive_bk :
165+ figManager = _pylab_helpers .Gcf .get_active ()
166+ if figManager is not None :
167+ canvas = figManager .canvas
168+ canvas .draw ()
169+ was_interactive = isinteractive ()
170+ if not was_interactive :
171+ ion ()
172+ show ()
173+ canvas .start_event_loop (interval )
174+ if not was_interactive :
175+ ioff ()
176+ return
177+
178+ # No on-screen figure is active, so sleep() is all we need.
179+ import time
180+ time .sleep (interval )
181+
182+
183+
149184@docstring .copy_dedent (matplotlib .rc )
150185def rc (* args , ** kwargs ):
151186 matplotlib .rc (* args , ** kwargs )
@@ -958,7 +993,7 @@ def subplot_tool(targetfig=None):
958993
959994def tight_layout (pad = 1.2 , h_pad = None , w_pad = None ):
960995 """Adjust subplot parameters to give specified padding.
961-
996+
962997 Parameters
963998 ----------
964999 pad : float
0 commit comments