def print_figure(fig, fmt='png'):
    # When there's an empty figure, we shouldn't return anything, otherwise we
    # get big blank areas in the qt console.
    if not fig.axes:
        return

    fc = fig.get_facecolor()
    ec = fig.get_edgecolor()
    fig.set_facecolor('white')
    fig.set_edgecolor('white')
    try:
        bytes_io = BytesIO()
        # use 72 dpi to match QTConsole's dpi
        fig.canvas.print_figure(bytes_io, format=fmt, dpi=72, bbox_inches='tight')
        data = bytes_io.getvalue()
    finally:
        fig.set_facecolor(fc)
        fig.set_edgecolor(ec)
    return data


# We need a little factory function here to create the closure where
# safe_execfile can live.
Initialize the report instance.
dataset/ETHPy150Open ipython/ipython-py3k/IPython/lib/pylabtools.py/print_figure--crossover with--dataset/ETHPy150Open kivy/plyer/plyer/tools/pep8checker/pep8.py/StyleGuide.init_report