##// END OF EJS Templates
use display instead of send_figure in inline backend hooks...
MinRK -
Show More
@@ -15,6 +15,7 b' from matplotlib._pylab_helpers import Gcf'
15
15
16 # Local imports.
16 # Local imports.
17 from IPython.config.configurable import SingletonConfigurable
17 from IPython.config.configurable import SingletonConfigurable
18 from IPython.core.display import display
18 from IPython.core.displaypub import publish_display_data
19 from IPython.core.displaypub import publish_display_data
19 from IPython.core.pylabtools import print_figure, select_figure_format
20 from IPython.core.pylabtools import print_figure, select_figure_format
20 from IPython.utils.traitlets import Dict, Instance, CaselessStrEnum, CBool
21 from IPython.utils.traitlets import Dict, Instance, CaselessStrEnum, CBool
@@ -102,7 +103,7 b' def show(close=None):'
102 close = InlineBackend.instance().close_figures
103 close = InlineBackend.instance().close_figures
103 try:
104 try:
104 for figure_manager in Gcf.get_all_fig_managers():
105 for figure_manager in Gcf.get_all_fig_managers():
105 send_figure(figure_manager.canvas.figure)
106 display(figure_manager.canvas.figure)
106 finally:
107 finally:
107 show._to_draw = []
108 show._to_draw = []
108 if close:
109 if close:
@@ -138,7 +139,7 b' def draw_if_interactive():'
138
139
139 if not hasattr(fig, 'show'):
140 if not hasattr(fig, 'show'):
140 # Queue up `fig` for display
141 # Queue up `fig` for display
141 fig.show = lambda *a: send_figure(fig)
142 fig.show = lambda *a: display(fig)
142
143
143 # If matplotlib was manually set to non-interactive mode, this function
144 # If matplotlib was manually set to non-interactive mode, this function
144 # should be a no-op (otherwise we'll generate duplicate plots, since a user
145 # should be a no-op (otherwise we'll generate duplicate plots, since a user
@@ -191,7 +192,7 b' def flush_figures():'
191 active = set([fm.canvas.figure for fm in Gcf.get_all_fig_managers()])
192 active = set([fm.canvas.figure for fm in Gcf.get_all_fig_managers()])
192 for fig in [ fig for fig in show._to_draw if fig in active ]:
193 for fig in [ fig for fig in show._to_draw if fig in active ]:
193 try:
194 try:
194 send_figure(fig)
195 display(fig)
195 except Exception as e:
196 except Exception as e:
196 # safely show traceback if in IPython, else raise
197 # safely show traceback if in IPython, else raise
197 try:
198 try:
General Comments 0
You need to be logged in to leave comments. Login now