Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use explicit kwarg for plt.show()#11170

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
dstansby wants to merge3 commits intomatplotlib:masterfromdstansby:show-kwarg
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletionsdoc/api/next_api_changes/2018-05-06-DS.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
Default value for ``block`` keyword arg standardised to ``True``
----------------------------------------------------------------

The ``block`` keyword argument that can be supplied to `.pyplot.show()` now
takes a default value of ``True`` instead of ``None``. The behaviour is
otherwise the same, and the `.backend_bases.FigureManagerBase.show()` has
also had this change applied.
15 changes: 6 additions & 9 deletionslib/matplotlib/backend_bases.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -177,12 +177,11 @@ def draw_if_interactive(cls):
cls.trigger_manager_draw(manager)

@classmethod
def show(cls, block=None):
def show(cls, block=True):
"""Show all figures.

`show` blocks by calling `mainloop` if *block* is ``True``, or if it
is ``None`` and we are neither in IPython's ``%pylab`` mode, nor in
`interactive` mode.
`show` blocks by calling `mainloop` if *block* is ``True`` and we are
neither in IPython's ``%pylab`` mode, nor in `interactive` mode.
"""
managers = Gcf.get_all_fig_managers()
if not managers:
Expand All@@ -198,7 +197,7 @@ def show(cls, block=None):
return
if cls.mainloop is None:
return
if block is None:
if block:
# Hack: Are we in IPython's pylab mode?
from matplotlib import pyplot
try:
Expand All@@ -210,8 +209,6 @@ def show(cls, block=None):
block = not ipython_pylab and not is_interactive()
# TODO: The above is a hack to get the WebAgg backend working with
# ipython's `%pylab` mode until proper integration is implemented.
if get_backend() == "WebAgg":
block = True
if block:
cls.mainloop()

Expand DownExpand Up@@ -244,7 +241,7 @@ class ShowBase(_Backend):
Subclass must override mainloop() method.
"""

def __call__(self, block=None):
def __call__(self, block=True):
return self.show(block=block)


Expand DownExpand Up@@ -2635,7 +2632,7 @@ def notify_axes_change(fig):
if self.toolmanager is None and self.toolbar is not None:
self.toolbar.update()

def show(self):
def show(self, block=True):
"""
For GUI backends, show the figure window and redraw.
For non-GUI backends, raise an exception to be caught
Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/backends/backend_nbagg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -242,7 +242,7 @@ def trigger_manager_draw(manager):
manager.show()

@staticmethod
def show(*args, **kwargs):
def show(block=True):
## TODO: something to do when keyword block==False ?
from matplotlib._pylab_helpers import Gcf

Expand Down
2 changes: 1 addition & 1 deletionlib/matplotlib/backends/backend_template.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -172,7 +172,7 @@ def draw_if_interactive():
"""


def show(block=None):
def show(block=True):
"""
For image backends - is not required
For GUI backends - show() is usually the last line of a pylab script and
Expand Down
5 changes: 4 additions & 1 deletionlib/matplotlib/backends/backend_webagg.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -319,7 +319,10 @@ def trigger_manager_draw(manager):
manager.canvas.draw_idle()

@staticmethod
def show():
def show(block=True):
Copy link
Member

Choose a reason for hiding this comment

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

I thought we fixed this already....

if not block:
warnings.warn('The webagg backend does not support "block=False"')
block = True
WebAggApplication.initialize()

url = "http://127.0.0.1:{port}{prefix}".format(
Expand Down
13 changes: 8 additions & 5 deletionslib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -231,9 +231,10 @@ def switch_backend(newbackend):
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()


def show(*args, **kw):
def show(block=True):
"""
Display a figure.

When running in ipython with its pylab mode, display all
figures and return to the ipython prompt.

Expand All@@ -243,12 +244,14 @@ def show(*args, **kw):
non-interactive to interactive mode (not recommended). In
that case it displays the figures but does not block.

A single experimental keyword argument, *block*, may be
set to True or False to override the blocking behavior
described above.
Parameters
----------
block : bool, optional
Experimental; set to ``False`` to override the blocking
behavior described above.
"""
global _show
return _show(*args, **kw)
return _show(block=block)


def isinteractive():
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp