File tree 1 file changed +14
-3
lines changed 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -340,12 +340,23 @@ def _setup_canvas(self):
340
340
341
341
def show (self , warn = True ):
342
342
"""
343
- If using a GUI backend, display the figure window.
343
+ If using a GUI backend with pyplot, display the figure window.
344
+
345
+ If the figure was not created using
346
+ :func:`~matplotlib.pyplot.figure`, it will lack a
347
+ :class:`~matplotlib.backend_bases.FigureManagerBase`, and
348
+ will raise an AttributeError.
344
349
345
350
For non-GUI backends, this does nothing, in which case
346
- a warning will be issued if *warn* is True.
351
+ a warning will be issued if *warn* is True (default) .
347
352
"""
348
- manager = getattr (self .canvas , 'manager' )
353
+ try :
354
+ manager = getattr (self .canvas , 'manager' )
355
+ except AttributeError as err :
356
+ raise AttributeError ("%s\n Figure.show works only "
357
+ "for figures managed by pyplot,\n normally "
358
+ "created by pyplot.figure()." % err )
359
+
349
360
if manager is not None :
350
361
try :
351
362
manager .show ()
You can’t perform that action at this time.
0 commit comments