W3cubDocs

/Matplotlib 3.5

matplotlib.pyplot.show

matplotlib.pyplot.show(*, block=None)[source]

Display all open figures.

Parameters
blockbool, optional

Whether to wait for all figures to be closed before returning.

If True block and run the GUI main loop until all figure windows are closed.

If False ensure that all figure windows are displayed and return immediately. In this case, you are responsible for ensuring that the event loop is running to have responsive figures.

Defaults to True in non-interactive mode and to False in interactive mode (see pyplot.isinteractive).

See also

ion

Enable interactive mode, which shows / updates the figure after every plotting command, so that calling show() is not necessary.

ioff

Disable interactive mode.

savefig

Save the figure to an image file instead of showing it on screen.

Notes

Saving figures to file and showing a window at the same time

If you want an image file as well as a user interface window, use pyplot.savefig before pyplot.show. At the end of (a blocking) show() the figure is closed and thus unregistered from pyplot. Calling pyplot.savefig afterwards would save a new and thus empty figure. This limitation of command order does not apply if the show is non-blocking or if you keep a reference to the figure and use Figure.savefig.

Auto-show in jupyter notebooks

The jupyter backends (activated via %matplotlib inline, %matplotlib notebook, or %matplotlib widget), call show() at the end of every cell by default. Thus, you usually don't have to call it explicitly there.

Examples using matplotlib.pyplot.show

===

MRI

© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/_as_gen/matplotlib.pyplot.show.html