@@ -365,6 +365,14 @@ def isinteractive():
365365
366366
367367class _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+
368376 def __init__ (self ):
369377 self .wasinteractive = isinteractive ()
370378 matplotlib .interactive (False )
@@ -380,6 +388,14 @@ def __exit__(self, exc_type, exc_value, traceback):
380388
381389
382390class _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+
383399 def __init__ (self ):
384400 self .wasinteractive = isinteractive ()
385401 matplotlib .interactive (True )
@@ -392,7 +408,6 @@ def __exit__(self, exc_type, exc_value, traceback):
392408 if not self .wasinteractive :
393409 matplotlib .interactive (False )
394410 uninstall_repl_displayhook ()
395- self ._used
396411
397412
398413def ioff ():
@@ -409,8 +424,7 @@ def ioff():
409424
410425 Notes
411426 -----
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::
414428
415429 with plt.ioff():
416430 # interactive mode will be off
@@ -420,6 +434,10 @@ def ioff():
420434
421435 # This figure will be shown immediately
422436 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.
423441 """
424442 return _ioff ()
425443
@@ -438,8 +456,7 @@ def ion():
438456
439457 Notes
440458 -----
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::
443460
444461 # if interactive mode is off
445462 # then figures will not be shown on creation
@@ -452,6 +469,10 @@ def ion():
452469 # figures will automatically be shown
453470 fig1 = plt.figure()
454471 # ...
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.
455476 """
456477 return _ion ()
457478
0 commit comments