Use explicit kwarg for plt.show() by dstansby · Pull Request #11170 · matplotlib/matplotlib · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 deletions doc/api/next_api_changes/2018-05-06-DS.rst
15 changes: 6 additions & 9 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff 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 Down Expand 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 Down Expand 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 deletion lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff 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 deletion lib/matplotlib/backends/backend_template.py
Original file line number Diff line number Diff 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 deletion lib/matplotlib/backends/backend_webagg.py
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):

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.

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 deletions lib/matplotlib/pyplot.py