##// END OF EJS Templates
MNT: ensure we can show un-pickled figures...
Thomas A Caswell -
Show More
@@ -123,14 +123,18 b" def print_figure(fig, fmt='png', bbox_inches='tight', **kwargs):"
123 123 }
124 124 # **kwargs get higher priority
125 125 kw.update(kwargs)
126
126
127 127 bytes_io = BytesIO()
128 if fig.canvas is None:
129 from matplotlib.backend_bases import FigureCanvasBase
130 FigureCanvasBase(fig)
131
128 132 fig.canvas.print_figure(bytes_io, **kw)
129 133 data = bytes_io.getvalue()
130 134 if fmt == 'svg':
131 135 data = data.decode('utf-8')
132 136 return data
133
137
134 138 def retina_figure(fig, **kwargs):
135 139 """format a figure as a pixel-doubled (retina) PNG"""
136 140 pngdata = print_figure(fig, fmt='retina', **kwargs)
@@ -248,3 +248,9 b' class TestPylabSwitch(object):'
248 248 def test_no_gui_backends():
249 249 for k in ['agg', 'svg', 'pdf', 'ps']:
250 250 assert k not in pt.backend2gui
251
252
253 def test_figure_no_canvas():
254 fig = Figure()
255 fig.canvas = None
256 pt.print_figure(fig)
General Comments 0
You need to be logged in to leave comments. Login now