Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Figure.show: clarify docstring and error message #1220

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

Merged
merged 1 commit into from
Sep 8, 2012
Merged
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
17 changes: 14 additions & 3 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,23 @@ def _setup_canvas(self):

def show(self, warn=True):
"""
If using a GUI backend, display the figure window.
If using a GUI backend with pyplot, display the figure window.

If the figure was not created using
:func:`~matplotlib.pyplot.figure`, it will lack a
:class:`~matplotlib.backend_bases.FigureManagerBase`, and
will raise an AttributeError.

For non-GUI backends, this does nothing, in which case
a warning will be issued if *warn* is True.
a warning will be issued if *warn* is True (default).
"""
manager = getattr(self.canvas, 'manager')
try:
manager = getattr(self.canvas, 'manager')
except AttributeError as err:
raise AttributeError("%s\n Figure.show works only "
"for figures managed by pyplot,\n normally "
"created by pyplot.figure()." % err)

if manager is not None:
try:
manager.show()
Expand Down