@@ -365,6 +365,14 @@ def isinteractive():
365
365
366
366
367
367
class _ioff :
368
+ """
369
+ Context manager for `.ioff`.
370
+
371
+ The state is changed in ``__init__()`` instead of ``__enter__()``. The
372
+ latter is a no-op. This allows using `.ioff` both as a function and
373
+ as a context.
374
+ """
375
+
368
376
def __init__ (self ):
369
377
self .wasinteractive = isinteractive ()
370
378
matplotlib .interactive (False )
@@ -380,6 +388,14 @@ def __exit__(self, exc_type, exc_value, traceback):
380
388
381
389
382
390
class _ion :
391
+ """
392
+ Context manager for `.ion`.
393
+
394
+ The state is changed in ``__init__()`` instead of ``__enter__()``. The
395
+ latter is a no-op. This allows using `.ion` both as a function and
396
+ as a context.
397
+ """
398
+
383
399
def __init__ (self ):
384
400
self .wasinteractive = isinteractive ()
385
401
matplotlib .interactive (True )
@@ -392,7 +408,6 @@ def __exit__(self, exc_type, exc_value, traceback):
392
408
if not self .wasinteractive :
393
409
matplotlib .interactive (False )
394
410
uninstall_repl_displayhook ()
395
- self ._used
396
411
397
412
398
413
def ioff ():
@@ -409,8 +424,7 @@ def ioff():
409
424
410
425
Notes
411
426
-----
412
- If you want the effects of this function to be temporary, it can
413
- be used as a context manager, for example::
427
+ For a temporary change, this can be used as a context manager::
414
428
415
429
with plt.ioff():
416
430
# interactive mode will be off
@@ -420,6 +434,10 @@ def ioff():
420
434
421
435
# This figure will be shown immediately
422
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.
423
441
"""
424
442
return _ioff ()
425
443
@@ -438,8 +456,7 @@ def ion():
438
456
439
457
Notes
440
458
-----
441
- If you want the effects of this function to be temporary, it can
442
- be used as a context manager, for example::
459
+ For a temporary change, this can be used as a context manager::
443
460
444
461
# if interactive mode is off
445
462
# then figures will not be shown on creation
@@ -452,6 +469,10 @@ def ion():
452
469
# figures will automatically be shown
453
470
fig1 = plt.figure()
454
471
# ...
472
+
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.
455
476
"""
456
477
return _ion ()
457
478
0 commit comments