Skip to content

Commit 007561d

Browse files
authored
Merge pull request #19863 from timhoffm/interactive
Cleanup docstrings related to interactive mode
2 parents 7c94e74 + 4b41705 commit 007561d

File tree

3 files changed

+44
-26
lines changed

3 files changed

+44
-26
lines changed

doc/devel/contributing.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ The definition of the pylab text function is a simple pass-through to
354354

355355
# in pylab.py
356356
def text(*args, **kwargs):
357-
ret = gca().text(*args, **kwargs)
358-
draw_if_interactive()
359-
return ret
357+
return gca().text(*args, **kwargs)
360358

361359
`~matplotlib.axes.Axes.text` in simplified form looks like this, i.e., it just
362360
passes all ``args`` and ``kwargs`` on to ``matplotlib.text.Text.__init__``::

lib/matplotlib/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,14 @@ def interactive(b):
11371137

11381138

11391139
def is_interactive():
1140-
"""Return whether to redraw after every plotting command."""
1140+
"""
1141+
Return whether to redraw after every plotting command.
1142+
1143+
.. note::
1144+
1145+
This function is only intended for use in backends. End users should
1146+
use `.pyplot.isinteractive` instead.
1147+
"""
11411148
return rcParams['interactive']
11421149

11431150

lib/matplotlib/pyplot.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ def new_figure_manager(*args, **kwargs):
307307

308308
# This function's signature is rewritten upon backend-load by switch_backend.
309309
def draw_if_interactive(*args, **kwargs):
310+
"""
311+
Redraw the current figure if in interactive mode.
312+
313+
.. warning::
314+
315+
End users will typically not have to call this function because the
316+
the interactive mode takes care of this.
317+
"""
310318
return _backend_mod.draw_if_interactive(*args, **kwargs)
311319

312320

@@ -345,27 +353,30 @@ def show(*args, **kwargs):
345353

346354
def isinteractive():
347355
"""
348-
Return if pyplot is in "interactive mode" or not.
356+
Return whether plots are updated after every plotting command.
357+
358+
The interactive mode is mainly useful if you build plots from the command
359+
line and want to see the effect of each command while you are building the
360+
figure.
349361
350-
If in interactive mode then:
362+
In interactive mode:
351363
352364
- newly created figures will be shown immediately;
353365
- figures will automatically redraw on change;
354366
- `.pyplot.show` will not block by default.
355367
356-
If not in interactive mode then:
368+
In non-interactive mode:
357369
358370
- newly created figures and changes to figures will not be reflected until
359371
explicitly asked to be;
360372
- `.pyplot.show` will block by default.
361373
362374
See Also
363375
--------
364-
ion : enable interactive mode
365-
ioff : disable interactive mode
366-
367-
show : show windows (and maybe block)
368-
pause : show windows, run GUI event loop, and block for a time
376+
ion : Enable interactive mode.
377+
ioff : Disable interactive mode.
378+
show : Show all figures (and maybe block).
379+
pause : Show all figures, and block for a time.
369380
"""
370381
return matplotlib.is_interactive()
371382

@@ -424,15 +435,16 @@ def __exit__(self, exc_type, exc_value, traceback):
424435

425436
def ioff():
426437
"""
427-
Turn interactive mode off.
438+
Disable interactive mode.
439+
440+
See `.pyplot.isinteractive` for more details.
428441
429442
See Also
430443
--------
431-
ion : enable interactive mode
432-
isinteractive : query current state
433-
434-
show : show windows (and maybe block)
435-
pause : show windows, run GUI event loop, and block for a time
444+
ion : Enable interactive mode.
445+
isinteractive : Whether interactive mode is enabled.
446+
show : Show all figures (and maybe block).
447+
pause : Show all figures, and block for a time.
436448
437449
Notes
438450
-----
@@ -459,15 +471,16 @@ def ioff():
459471

460472
def ion():
461473
"""
462-
Turn interactive mode on.
474+
Enable interactive mode.
475+
476+
See `.pyplot.isinteractive` for more details.
463477
464478
See Also
465479
--------
466-
ioff : disable interactive mode
467-
isinteractive : query current state
468-
469-
show : show windows (and maybe block)
470-
pause : show windows, run GUI event loop, and block for a time
480+
ioff : Disable interactive mode.
481+
isinteractive : Whether interactive mode is enabled.
482+
show : Show all figures (and maybe block).
483+
pause : Show all figures, and block for a time.
471484
472485
Notes
473486
-----
@@ -506,8 +519,8 @@ def pause(interval):
506519
507520
See Also
508521
--------
509-
matplotlib.animation : Complex animation
510-
show : show figures and optional block forever
522+
matplotlib.animation : Proper animations
523+
show : Show all figures and optional block until all figures are closed.
511524
"""
512525
manager = _pylab_helpers.Gcf.get_active()
513526
if manager is not None:

0 commit comments

Comments
 (0)