##// END OF EJS Templates
reshow nbagg figures on display...
Min RK -
Show More
@@ -173,6 +173,16 b' def mpl_runner(safe_execfile):'
173 return mpl_execfile
173 return mpl_execfile
174
174
175
175
176 def _reshow_nbagg_figure(fig):
177 """reshow an nbagg figure"""
178 try:
179 reshow = fig.canvas.manager.reshow
180 except AttributeError:
181 raise NotImplementedError()
182 else:
183 reshow()
184
185
176 def select_figure_formats(shell, formats, **kwargs):
186 def select_figure_formats(shell, formats, **kwargs):
177 """Select figure formats for the inline backend.
187 """Select figure formats for the inline backend.
178
188
@@ -185,6 +195,7 b' def select_figure_formats(shell, formats, **kwargs):'
185 **kwargs : any
195 **kwargs : any
186 Extra keyword arguments to be passed to fig.canvas.print_figure.
196 Extra keyword arguments to be passed to fig.canvas.print_figure.
187 """
197 """
198 import matplotlib
188 from matplotlib.figure import Figure
199 from matplotlib.figure import Figure
189 from ipykernel.pylab import backend_inline
200 from ipykernel.pylab import backend_inline
190
201
@@ -199,7 +210,11 b' def select_figure_formats(shell, formats, **kwargs):'
199 formats = set(formats)
210 formats = set(formats)
200
211
201 [ f.pop(Figure, None) for f in shell.display_formatter.formatters.values() ]
212 [ f.pop(Figure, None) for f in shell.display_formatter.formatters.values() ]
202
213
214 if matplotlib.backends.backend.lower() == 'nbagg':
215 formatter = shell.display_formatter.ipython_display_formatter
216 formatter.for_type(Figure, _reshow_nbagg_figure)
217
203 supported = {'png', 'png2x', 'retina', 'jpg', 'jpeg', 'svg', 'pdf'}
218 supported = {'png', 'png2x', 'retina', 'jpg', 'jpeg', 'svg', 'pdf'}
204 bad = formats.difference(supported)
219 bad = formats.difference(supported)
205 if bad:
220 if bad:
General Comments 0
You need to be logged in to leave comments. Login now