File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -340,12 +340,23 @@ def _setup_canvas(self):
340340
341341 def show (self , warn = True ):
342342 """
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.
344349
345350 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) .
347352 """
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+
349360 if manager is not None :
350361 try :
351362 manager .show ()
You can’t perform that action at this time.
0 commit comments