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

Skip to content

Commit b2a4753

Browse files
tacaswellmeeseeksmachine
authored andcommitted
Backport PR #19863: Cleanup docstrings related to interactive mode
1 parent d0934c6 commit b2a4753

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

@@ -356,27 +364,30 @@ def show(*args, **kwargs):
356364

357365
def isinteractive():
358366
"""
359-
Return if pyplot is in "interactive mode" or not.
367+
Return whether plots are updated after every plotting command.
368+
369+
The interactive mode is mainly useful if you build plots from the command
370+
line and want to see the effect of each command while you are building the
371+
figure.
360372
361-
If in interactive mode then:
373+
In interactive mode:
362374
363375
- newly created figures will be shown immediately;
364376
- figures will automatically redraw on change;
365377
- `.pyplot.show` will not block by default.
366378
367-
If not in interactive mode then:
379+
In non-interactive mode:
368380
369381
- newly created figures and changes to figures will not be reflected until
370382
explicitly asked to be;
371383
- `.pyplot.show` will block by default.
372384
373385
See Also
374386
--------
375-
ion : enable interactive mode
376-
ioff : disable interactive mode
377-
378-
show : show windows (and maybe block)
379-
pause : show windows, run GUI event loop, and block for a time
387+
ion : Enable interactive mode.
388+
ioff : Disable interactive mode.
389+
show : Show all figures (and maybe block).
390+
pause : Show all figures, and block for a time.
380391
"""
381392
return matplotlib.is_interactive()
382393

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

436447
def ioff():
437448
"""
438-
Turn interactive mode off.
449+
Disable interactive mode.
450+
451+
See `.pyplot.isinteractive` for more details.
439452
440453
See Also
441454
--------
442-
ion : enable interactive mode
443-
isinteractive : query current state
444-
445-
show : show windows (and maybe block)
446-
pause : show windows, run GUI event loop, and block for a time
455+
ion : Enable interactive mode.
456+
isinteractive : Whether interactive mode is enabled.
457+
show : Show all figures (and maybe block).
458+
pause : Show all figures, and block for a time.
447459
448460
Notes
449461
-----
@@ -470,15 +482,16 @@ def ioff():
470482

471483
def ion():
472484
"""
473-
Turn interactive mode on.
485+
Enable interactive mode.
486+
487+
See `.pyplot.isinteractive` for more details.
474488
475489
See Also
476490
--------
477-
ioff : disable interactive mode
478-
isinteractive : query current state
479-
480-
show : show windows (and maybe block)
481-
pause : show windows, run GUI event loop, and block for a time
491+
ioff : Disable interactive mode.
492+
isinteractive : Whether interactive mode is enabled.
493+
show : Show all figures (and maybe block).
494+
pause : Show all figures, and block for a time.
482495
483496
Notes
484497
-----
@@ -517,8 +530,8 @@ def pause(interval):
517530
518531
See Also
519532
--------
520-
matplotlib.animation : Complex animation
521-
show : show figures and optional block forever
533+
matplotlib.animation : Proper animations
534+
show : Show all figures and optional block until all figures are closed.
522535
"""
523536
manager = _pylab_helpers.Gcf.get_active()
524537
if manager is not None:

0 commit comments

Comments
 (0)