Permalink
Browse files

Merge pull request #1220 from efiring/clarify_figure_show

Figure.show: clarify docstring and error message
  • Loading branch information...
2 parents 820985a + 930b262 commit 32dc9471c8bf2e0c17547cdfec3b2786c305552c @efiring committed Sep 8, 2012
Showing with 14 additions and 3 deletions.
  1. +14 −3 lib/matplotlib/figure.py
View
17 lib/matplotlib/figure.py
@@ -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()

0 comments on commit 32dc947

Please sign in to comment.