Skip to content

Commit

Permalink
Merge pull request #1220 from efiring/clarify_figure_show
Browse files Browse the repository at this point in the history
Figure.show: clarify docstring and error message
  • Loading branch information
efiring committed Sep 8, 2012
2 parents 820985a + 930b262 commit 32dc947
Showing 1 changed file with 14 additions and 3 deletions.
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

0 comments on commit 32dc947

Please sign in to comment.