From 8965c22a2a14fe337c90a224df00ecf703a6489a 2012-07-14 23:55:00 From: Min RK Date: 2012-07-14 23:55:00 Subject: [PATCH] Merge pull request #2074 from tkf/inlinebg Make BG color of inline plot configurable via InlineBackend.rc --- diff --git a/IPython/core/pylabtools.py b/IPython/core/pylabtools.py index eca72fe..9fd9cd6 100644 --- a/IPython/core/pylabtools.py +++ b/IPython/core/pylabtools.py @@ -97,15 +97,10 @@ def print_figure(fig, fmt='png'): fc = fig.get_facecolor() ec = fig.get_edgecolor() - fig.set_facecolor('white') - fig.set_edgecolor('white') - try: - bytes_io = BytesIO() - fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight') - data = bytes_io.getvalue() - finally: - fig.set_facecolor(fc) - fig.set_edgecolor(ec) + bytes_io = BytesIO() + fig.canvas.print_figure(bytes_io, format=fmt, bbox_inches='tight', + facecolor=fc, edgecolor=ec) + data = bytes_io.getvalue() return data diff --git a/IPython/zmq/pylab/backend_inline.py b/IPython/zmq/pylab/backend_inline.py index 2401cb9..469d74c 100644 --- a/IPython/zmq/pylab/backend_inline.py +++ b/IPython/zmq/pylab/backend_inline.py @@ -40,6 +40,9 @@ class InlineBackend(InlineBackendConfig): # so we shrink the figure size to 6x4, and tweak fonts to # make that fit. rc = Dict({'figure.figsize': (6.0,4.0), + # play nicely with white background in the Qt and notebook frontend + 'figure.facecolor': 'white', + 'figure.edgecolor': 'white', # 12pt labels get cutoff on 6x4 logplots, so use 10pt. 'font.size': 10, # 72 dpi matches SVG/qtconsole