-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Doc changes to plt.show #11720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doc changes to plt.show #11720
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be shortend: "Whether the execution is blocked until the figures are closed." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternative suggestion:
|
||
and False means that the python execution continues after the figures | ||
are displayed. | ||
|
||
The default behavior is different in interactive and non-interactive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shorter: The default is True unless interactive mode is enabled or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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(): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would it not do anything in interactive mode? I think it also shows the figure there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.