File tree 3 files changed +9
-18
lines changed 3 files changed +9
-18
lines changed Original file line number Diff line number Diff line change @@ -185,14 +185,8 @@ def show(cls, block=None):
185
185
if not managers :
186
186
return
187
187
for manager in managers :
188
- try :
189
- manager .show ()
190
- except NonGuiException :
191
- warnings .warn (
192
- ('matplotlib is currently using %s, which is a ' +
193
- 'non-GUI backend, so cannot show the figure.' )
194
- % get_backend ())
195
- return
188
+ # Emits a warning if the backend is non-interactive.
189
+ manager .canvas .figure .show ()
196
190
if cls .mainloop is None :
197
191
return
198
192
if block is None :
Original file line number Diff line number Diff line change @@ -439,10 +439,9 @@ def show(self, warn=True):
439
439
except NonGuiException :
440
440
pass
441
441
if warn :
442
- warnings .warn (
443
- ('matplotlib is currently using %s, which is a ' +
444
- 'non-GUI backend, so cannot show the figure.' )
445
- % get_backend ())
442
+ warnings .warn ('Matplotlib is currently using %s, which is a '
443
+ 'non-GUI backend, so cannot show the figure.'
444
+ % get_backend ())
446
445
447
446
def _get_axes (self ):
448
447
return self ._axstack .as_list ()
Original file line number Diff line number Diff line change @@ -69,13 +69,11 @@ def test_non_gui_warning():
69
69
with pytest .warns (UserWarning ) as rec :
70
70
plt .show ()
71
71
assert len (rec ) == 1
72
- assert 'matplotlib is currently using pdf, ' \
73
- 'which is a non-GUI backend' \
74
- in str (rec [0 ].message )
72
+ assert ('Matplotlib is currently using pdf, which is a non-GUI backend'
73
+ in str (rec [0 ].message ))
75
74
76
75
with pytest .warns (UserWarning ) as rec :
77
76
plt .gcf ().show ()
78
77
assert len (rec ) == 1
79
- assert 'matplotlib is currently using pdf, ' \
80
- 'which is a non-GUI backend' \
81
- in str (rec [0 ].message )
78
+ assert ('Matplotlib is currently using pdf, which is a non-GUI backend'
79
+ in str (rec [0 ].message ))
You can’t perform that action at this time.
0 commit comments