@@ -364,7 +364,7 @@ def isinteractive():
364
364
return matplotlib .is_interactive ()
365
365
366
366
367
- class _ioff :
367
+ class _IoffContext :
368
368
"""
369
369
Context manager for `.ioff`.
370
370
@@ -387,7 +387,7 @@ def __exit__(self, exc_type, exc_value, traceback):
387
387
install_repl_displayhook ()
388
388
389
389
390
- class _ion :
390
+ class _IonContext :
391
391
"""
392
392
Context manager for `.ion`.
393
393
@@ -426,20 +426,23 @@ def ioff():
426
426
-----
427
427
For a temporary change, this can be used as a context manager::
428
428
429
+ # if interactive mode is on
430
+ # then figures will be shown on creation
431
+ plt.ion()
432
+ # This figure will be shown immediately
433
+ fig = plt.figure()
434
+
429
435
with plt.ioff():
430
436
# interactive mode will be off
431
437
# figures will not automatically be shown
432
- fig1 = plt.figure()
438
+ fig2 = plt.figure()
433
439
# ...
434
440
435
- # This figure will be shown immediately
436
- fig2 = plt.figure()
437
-
438
- The return value of `plt.ioff` is necessary to make the function work
439
- as a context manager. It is not intended to be stored or accessed
440
- by the user.
441
+ To enable usage as a context manager, this function returns an
442
+ ``_IoffContext`` object. The return value is not intended to be stored
443
+ or accessed by the user.
441
444
"""
442
- return _ioff ()
445
+ return _IoffContext ()
443
446
444
447
445
448
def ion ():
@@ -448,7 +451,7 @@ def ion():
448
451
449
452
See Also
450
453
--------
451
- ion : enable interactive mode
454
+ ioff : disable interactive mode
452
455
isinteractive : query current state
453
456
454
457
show : show windows (and maybe block)
@@ -462,19 +465,19 @@ def ion():
462
465
# then figures will not be shown on creation
463
466
plt.ioff()
464
467
# This figure will not be shown immediately
465
- fig2 = plt.figure()
468
+ fig = plt.figure()
466
469
467
470
with plt.ion():
468
471
# interactive mode will be on
469
472
# figures will automatically be shown
470
- fig1 = plt.figure()
473
+ fig2 = plt.figure()
471
474
# ...
472
475
473
- The return value of `plt.ion` is necessary to make the function work
474
- as a context manager. It is not intended to be stored or accessed
475
- by the user.
476
+ To enable usage as a context manager, this function returns an
477
+ ``_IonContext`` object. The return value is not intended to be stored
478
+ or accessed by the user.
476
479
"""
477
- return _ion ()
480
+ return _IonContext ()
478
481
479
482
480
483
def pause (interval ):
0 commit comments