def print_figure(fig, fmt='<STR_LIT>'):
<EOL>if not fig.axes and not fig.lines:<EOL><INDENT>return<EOL><DEDENT>fc = fig.get_facecolor()<EOL>ec = fig.get_edgecolor()<EOL>fig.set_facecolor('<STR_LIT>')<EOL>fig.set_edgecolor('<STR_LIT>')<EOL>try:<EOL><INDENT>bytes_io = BytesIO()<EOL>fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='<STR_LIT>')<EOL>data = bytes_io.getvalue()<EOL><DEDENT>finally:<EOL><INDENT>fig.set_facecolor(fc)<EOL>fig.set_edgecolor(ec)<EOL><DEDENT>return data<EOL>
Convert a figure to svg or png for inline display.