Show all figures. This method is the implementation of `.pyplot.show`. To customize the behavior of `.pyplot.show`, interactive backends should usually override `~.FigureManagerBase.start_main_loop`; if more customized logic is necessary, `~.FigureManagerBase.pyplo
(cls, *, block=None)
| 2823 | |
| 2824 | @classmethod |
| 2825 | def pyplot_show(cls, *, block=None): |
| 2826 | """ |
| 2827 | Show all figures. This method is the implementation of `.pyplot.show`. |
| 2828 | |
| 2829 | To customize the behavior of `.pyplot.show`, interactive backends |
| 2830 | should usually override `~.FigureManagerBase.start_main_loop`; if more |
| 2831 | customized logic is necessary, `~.FigureManagerBase.pyplot_show` can |
| 2832 | also be overridden. |
| 2833 | |
| 2834 | Parameters |
| 2835 | ---------- |
| 2836 | block : bool, optional |
| 2837 | Whether to block by calling ``start_main_loop``. The default, |
| 2838 | None, means to block if we are neither in IPython's ``%pylab`` mode |
| 2839 | nor in ``interactive`` mode. |
| 2840 | """ |
| 2841 | managers = Gcf.get_all_fig_managers() |
| 2842 | if not managers: |
| 2843 | return |
| 2844 | for manager in managers: |
| 2845 | try: |
| 2846 | manager.show() # Emits a warning for non-interactive backend. |
| 2847 | except NonGuiException as exc: |
| 2848 | _api.warn_external(str(exc)) |
| 2849 | if block is None: |
| 2850 | # Hack: Are we in IPython's %pylab mode? In pylab mode, IPython |
| 2851 | # (>= 0.10) tacks a _needmain attribute onto pyplot.show (always |
| 2852 | # set to False). |
| 2853 | pyplot_show = getattr(sys.modules.get("matplotlib.pyplot"), "show", None) |
| 2854 | ipython_pylab = hasattr(pyplot_show, "_needmain") |
| 2855 | block = not ipython_pylab and not is_interactive() |
| 2856 | if block: |
| 2857 | cls.start_main_loop() |
| 2858 | |
| 2859 | def show(self): |
| 2860 | """ |
nothing calls this directly
no test coverage detected