FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Doc changes to plt.show by fredrik-1 · Pull Request #11720 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion lib/matplotlib/backends/backend_webagg.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,10 @@ def trigger_manager_draw(manager):
manager.canvas.draw_idle()

@staticmethod
def show():
def show(block=True):
if not block:
block = True

WebAggApplication.initialize()

url = "http://127.0.0.1:{port}{prefix}".format(
Expand Down
56 changes: 43 additions & 13 deletions lib/matplotlib/pyplot.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,54 @@ def switch_backend(newbackend):
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()


def show(*args, **kw):
def show(block=None):
"""
Display a figure.
When running in ipython with its pylab mode, display all
figures and return to the ipython prompt.
Draw and display all figures.

In non-interactive mode, display all figures and block until
the figures have been closed; in interactive mode it has no
effect unless figures were created prior to a change from
non-interactive to interactive mode (not recommended). In
that case it displays the figures but does not block.
Mainly used in non-interactive mode to draw and display
the figures. It usually does nothing in interactive mode.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why would it not do anything in interactive mode? I think it also shows the figure there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I am not sure. It was written in the old docstring that it does nothing.

When I test it in spyder, the only difference is that the "thumbnail" in the toolbar start to blink if plt.show() is used. The figure window don't pop up to the front or something like that.


A single experimental keyword argument, *block*, may be
set to True or False to override the blocking behavior
described above.
Parameters
----------

block : bool or None
True means that the execution is blocked until the figures are closed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can be shortend: "Whether the execution is blocked until the figures are closed."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Alternative suggestion:

If True, the execution is blocked until all displayed figures are closed. If False, the python execution continues after the figures are displayed.

and False means that the python execution continues after the figures
are displayed.

The default behavior is different in interactive and non-interactive

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Shorter:

The default is True unless interactive mode is enabled or %matplotlib_ is used in IPython.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Wouldn't want to go for the long version here. It's just redundant and doesn't add to the clarity.

mode and whether or not `%matplotlib`_ is used in IPython. The default
is False in interactive mode and True in non-interactive mode except
when `%matplotlib`_ has been used in IPython, it is False in that case.

Notes
-----
Blocking is necessary when running ``python script.py`` to be able to see
the figures before the python session finish but blocking is often not the
expected behavior when running Python interactively.

The difference between non-interactive and interactive mode is that the
figures are drawn and updated automatically after each plot command in
interactive mode.

Interactive mode can be set on and off with `.pyplot.ion` and
`.pyplot.ioff` in both vanilla Python and IPython and set to on with
`%matplotlib`_ in IPython.

.. _`%matplotlib`:
http://ipython.readthedocs.io/en/stable/interactive/plotting.html#id1

See Also
--------
.pyplot.ion
.pyplot.ioff
.pyplot.isinteractive
"""
global _show
return _show(*args, **kw)
if block is not None:
if type(block) != bool:
raise TypeError('"block" should be a bool or None')
return _show(block=block)


def isinteractive():
Expand Down

Back | FazBrowse Home | New Git URL