Disable interactive mode. See `.pyplot.isinteractive` for more details. See Also -------- ion : Enable interactive mode. isinteractive : Whether interactive mode is enabled. show : Show all figures (and maybe block). pause : Show all figures, and block for a time.
()
| 681 | # See https://github.com/matplotlib/matplotlib/issues/27659 |
| 682 | # and https://github.com/matplotlib/matplotlib/pull/27667 for more info. |
| 683 | def ioff() -> AbstractContextManager: |
| 684 | """ |
| 685 | Disable interactive mode. |
| 686 | |
| 687 | See `.pyplot.isinteractive` for more details. |
| 688 | |
| 689 | See Also |
| 690 | -------- |
| 691 | ion : Enable interactive mode. |
| 692 | isinteractive : Whether interactive mode is enabled. |
| 693 | show : Show all figures (and maybe block). |
| 694 | pause : Show all figures, and block for a time. |
| 695 | |
| 696 | Notes |
| 697 | ----- |
| 698 | For a temporary change, this can be used as a context manager:: |
| 699 | |
| 700 | # if interactive mode is on |
| 701 | # then figures will be shown on creation |
| 702 | plt.ion() |
| 703 | # This figure will be shown immediately |
| 704 | fig = plt.figure() |
| 705 | |
| 706 | with plt.ioff(): |
| 707 | # interactive mode will be off |
| 708 | # figures will not automatically be shown |
| 709 | fig2 = plt.figure() |
| 710 | # ... |
| 711 | |
| 712 | To enable optional usage as a context manager, this function returns a |
| 713 | context manager object, which is not intended to be stored or |
| 714 | accessed by the user. |
| 715 | """ |
| 716 | stack = ExitStack() |
| 717 | stack.callback(ion if isinteractive() else ioff) |
| 718 | matplotlib.interactive(False) |
| 719 | uninstall_repl_displayhook() |
| 720 | return stack |
| 721 | |
| 722 | |
| 723 | # Note: The return type of ion being AbstractContextManager |
nothing calls this directly
no test coverage detected
searching dependent graphs…