File tree 1 file changed +12
-4
lines changed
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -175,20 +175,28 @@ def draw_if_interactive(cls):
175
175
cls .trigger_manager_draw (manager )
176
176
177
177
@classmethod
178
- def show (cls , block = None ):
178
+ def show (cls , block = None , warn = True ):
179
179
"""Show all figures.
180
180
181
181
`show` blocks by calling `mainloop` if *block* is ``True``, or if it
182
182
is ``None`` and we are neither in IPython's ``%pylab`` mode, nor in
183
183
`interactive` mode.
184
184
"""
185
- if cls .mainloop is None :
186
- return
187
185
managers = Gcf .get_all_fig_managers ()
188
186
if not managers :
189
187
return
190
188
for manager in managers :
191
- manager .show ()
189
+ try :
190
+ manager .show ()
191
+ except NonGuiException :
192
+ if warn :
193
+ import warnings
194
+ warnings .warn (
195
+ "matplotlib is currently using a non-GUI backend, "
196
+ "so cannot show the figure" )
197
+ return
198
+ if cls .mainloop is None :
199
+ return
192
200
if block is None :
193
201
# Hack: Are we in IPython's pylab mode?
194
202
from matplotlib import pyplot
You can’t perform that action at this time.
0 commit comments