##// END OF EJS Templates
Merge pull request #6612 from minrk/close-all-only-if-any...
Matthias Bussonnier -
r18137:86c4d270 merge
parent child Browse files
Show More
@@ -1,30 +1,19 b''
1 """A matplotlib backend for publishing figures via display_data"""
1 """A matplotlib backend for publishing figures via display_data"""
2 #-----------------------------------------------------------------------------
2
3 # Copyright (C) 2011 The IPython Development Team
3 # Copyright (c) IPython Development Team.
4 #
4 # Distributed under the terms of the Modified BSD License.
5 # Distributed under the terms of the BSD License. The full license is in
5
6 # the file COPYING, distributed as part of this software.
7 #-----------------------------------------------------------------------------
8
9 #-----------------------------------------------------------------------------
10 # Imports
11 #-----------------------------------------------------------------------------
12 from __future__ import print_function
6 from __future__ import print_function
13
7
14 # Third-party imports
15 import matplotlib
8 import matplotlib
16 from matplotlib.backends.backend_agg import new_figure_manager, FigureCanvasAgg # analysis: ignore
9 from matplotlib.backends.backend_agg import new_figure_manager, FigureCanvasAgg # analysis: ignore
17 from matplotlib._pylab_helpers import Gcf
10 from matplotlib._pylab_helpers import Gcf
18
11
19 # Local imports
20 from IPython.core.getipython import get_ipython
12 from IPython.core.getipython import get_ipython
21 from IPython.core.display import display
13 from IPython.core.display import display
22
14
23 from .config import InlineBackend
15 from .config import InlineBackend
24
16
25 #-----------------------------------------------------------------------------
26 # Functions
27 #-----------------------------------------------------------------------------
28
17
29 def show(close=None):
18 def show(close=None):
30 """Show all figures as SVG/PNG payloads sent to the IPython clients.
19 """Show all figures as SVG/PNG payloads sent to the IPython clients.
@@ -43,7 +32,9 b' def show(close=None):'
43 display(figure_manager.canvas.figure)
32 display(figure_manager.canvas.figure)
44 finally:
33 finally:
45 show._to_draw = []
34 show._to_draw = []
46 if close:
35 # only call close('all') if any to close
36 # close triggers gc.collect, which can be slow
37 if close and Gcf.get_all_fig_managers():
47 matplotlib.pyplot.close('all')
38 matplotlib.pyplot.close('all')
48
39
49
40
General Comments 0
You need to be logged in to leave comments. Login now