Skip to content

Commit d8efe5a

Browse files
committed
plt.show doc changes
1 parent 4bc1ca9 commit d8efe5a

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

lib/matplotlib/backends/backend_webagg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def trigger_manager_draw(manager):
319319
manager.canvas.draw_idle()
320320

321321
@staticmethod
322-
def show():
322+
def show(block=True):
323323
WebAggApplication.initialize()
324324

325325
url = "http://127.0.0.1:{port}{prefix}".format(

lib/matplotlib/pyplot.py

+40-13
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,51 @@ def switch_backend(newbackend):
230230
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
231231

232232

233-
def show(*args, **kw):
233+
def show(block=None):
234234
"""
235-
Display a figure.
236-
When running in ipython with its pylab mode, display all
237-
figures and return to the ipython prompt.
235+
Draw and display all figures.
238236
239-
In non-interactive mode, display all figures and block until
240-
the figures have been closed; in interactive mode it has no
241-
effect unless figures were created prior to a change from
242-
non-interactive to interactive mode (not recommended). In
243-
that case it displays the figures but does not block.
237+
Mainly used in non-interactive mode to draw and display
238+
the figures. It usually does nothing in interactive mode.
244239
245-
A single experimental keyword argument, *block*, may be
246-
set to True or False to override the blocking behavior
247-
described above.
240+
Parameters
241+
----------
242+
243+
block : bool or None
244+
True means that the execution is blocked until the figures are closed
245+
and False means that the python execution continues after the figures
246+
are displayed.
247+
248+
The default behavior is different in interactive and non-interactive
249+
mode and whether or not `%matplotlib`_ is used in IPython. The default
250+
is False in interactive mode and True in non-interactive mode except
251+
when `%matplotlib`_ has been used in IPython, it is False in that case.
252+
253+
Notes
254+
-----
255+
Blocking is necessary when running ``python script.py`` to be able to see
256+
the figures before the python session finish but blocking is often not the
257+
expected behavior when running Python interactively.
258+
259+
The difference between non-interactive and interactive mode is that the
260+
figures are drawn and updated automatically after each plot command in
261+
interactive mode.
262+
263+
Interactive mode can be set on and off with `.pyplot.ion` and
264+
`.pyplot.ioff` in both vanilla Python and IPython and set to on with
265+
`%matplotlib`_ in IPython.
266+
267+
.. _`%matplotlib`:
268+
http://ipython.readthedocs.io/en/stable/interactive/plotting.html#id1
269+
270+
See Also
271+
--------
272+
.pyplot.ion
273+
.pyplot.ioff
274+
.pyplot.isinteractive
248275
"""
249276
global _show
250-
return _show(*args, **kw)
277+
return _show(block=block)
251278

252279

253280
def isinteractive():

0 commit comments

Comments
 (0)