Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22fccfd

Browse files
authored
Merge pull request #19877 from meeseeksmachine/auto-backport-of-pr-19863-on-v3.4.x
Backport PR #19863 on branch v3.4.x (Cleanup docstrings related to interactive mode)
2 parents ab00287 + b2a4753 commit 22fccfd

3 files changed

Lines changed: 44 additions & 26 deletions

File tree

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
@@ -1112,7 +1112,14 @@ def interactive(b):
11121112

11131113

11141114
def is_interactive():
1115-
"""Return whether to redraw after every plotting command."""
1115+
"""
1116+
Return whether to redraw after every plotting command.
1117+
1118+
.. note::
1119+
1120+
This function is only intended for use in backends. End users should
1121+
use `.pyplot.isinteractive` instead.
1122+
"""
11161123
return rcParams['interactive']
11171124

11181125

lib/matplotlib/pyplot.py

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

319319
# This function's signature is rewritten upon backend-load by switch_backend.
320320
def draw_if_interactive(*args, **kwargs):
321+
"""
322+
Redraw the current figure if in interactive mode.
323+
324+
.. warning::
325+
326+
End users will typically not have to call this function because the
327+
the interactive mode takes care of this.
328+
"""
321329
return _backend_mod.draw_if_interactive(*args, **kwargs)
322330

323331

@@ -372,27 +380,30 @@ def show(*args, **kwargs):
372380

373381
def isinteractive():
374382
"""
375-
Return if pyplot is in "interactive mode" or not.
383+
Return whether plots are updated after every plotting command.
384+
385+
The interactive mode is mainly useful if you build plots from the command
386+
line and want to see the effect of each command while you are building the
387+
figure.
376388
377-
If in interactive mode then:
389+
In interactive mode:
378390
379391
- newly created figures will be shown immediately;
380392
- figures will automatically redraw on change;
381393
- `.pyplot.show` will not block by default.
382394
383-
If not in interactive mode then:
395+
In non-interactive mode:
384396
385397
- newly created figures and changes to figures will not be reflected until
386398
explicitly asked to be;
387399
- `.pyplot.show` will block by default.
388400
389401
See Also
390402
--------
391-
ion : enable interactive mode
392-
ioff : disable interactive mode
393-
394-
show : show windows (and maybe block)
395-
pause : show windows, run GUI event loop, and block for a time
403+
ion : Enable interactive mode.
404+
ioff : Disable interactive mode.
405+
show : Show all figures (and maybe block).
406+
pause : Show all figures, and block for a time.
396407
"""
397408
return matplotlib.is_interactive()
398409

@@ -451,15 +462,16 @@ def __exit__(self, exc_type, exc_value, traceback):
451462

452463
def ioff():
453464
"""
454-
Turn interactive mode off.
465+
Disable interactive mode.
466+
467+
See `.pyplot.isinteractive` for more details.
455468
456469
See Also
457470
--------
458-
ion : enable interactive mode
459-
isinteractive : query current state
460-
461-
show : show windows (and maybe block)
462-
pause : show windows, run GUI event loop, and block for a time
471+
ion : Enable interactive mode.
472+
isinteractive : Whether interactive mode is enabled.
473+
show : Show all figures (and maybe block).
474+
pause : Show all figures, and block for a time.
463475
464476
Notes
465477
-----
@@ -486,15 +498,16 @@ def ioff():
486498

487499
def ion():
488500
"""
489-
Turn interactive mode on.
501+
Enable interactive mode.
502+
503+
See `.pyplot.isinteractive` for more details.
490504
491505
See Also
492506
--------
493-
ioff : disable interactive mode
494-
isinteractive : query current state
495-
496-
show : show windows (and maybe block)
497-
pause : show windows, run GUI event loop, and block for a time
507+
ioff : Disable interactive mode.
508+
isinteractive : Whether interactive mode is enabled.
509+
show : Show all figures (and maybe block).
510+
pause : Show all figures, and block for a time.
498511
499512
Notes
500513
-----
@@ -533,8 +546,8 @@ def pause(interval):
533546
534547
See Also
535548
--------
536-
matplotlib.animation : Complex animation
537-
show : show figures and optional block forever
549+
matplotlib.animation : Proper animations
550+
show : Show all figures and optional block until all figures are closed.
538551
"""
539552
manager = _pylab_helpers.Gcf.get_active()
540553
if manager is not None:

0 commit comments

Comments
 (0)