diff --git a/IPython/lib/pylabtools.py b/IPython/lib/pylabtools.py index 3becc23..c38171c 100644 --- a/IPython/lib/pylabtools.py +++ b/IPython/lib/pylabtools.py @@ -109,8 +109,14 @@ def import_pylab(user_ns, backend, import_all=True, shell=None): # function that will pick up the results for display. This can only be # done with access to the real shell object. if backend == backends['inline']: - from IPython.zmq.pylab.backend_inline import flush_svg + from IPython.zmq.pylab.backend_inline import flush_svg, figsize + from matplotlib import pyplot shell.register_post_execute(flush_svg) + # The typical default figure size is too large for inline use. We + # might make this a user-configurable parameter later. + figsize(6.0, 4.0) + # Add 'figsize' to pyplot and to the user's namespace + user_ns['figsize'] = pyplot.figsize = figsize else: from IPython.zmq.pylab.backend_inline import pastefig from matplotlib import pyplot diff --git a/IPython/zmq/pylab/backend_inline.py b/IPython/zmq/pylab/backend_inline.py index 9d14e2e..f401aae 100644 --- a/IPython/zmq/pylab/backend_inline.py +++ b/IPython/zmq/pylab/backend_inline.py @@ -38,6 +38,16 @@ def show(close=True): show._draw_called = False +def figsize(sizex, sizey): + """Set the default figure size to be [sizex, sizey]. + + This is just an easy to remember, convenience wrapper that sets:: + + matplotlib.rcParams['figure.figsize'] = [sizex, sizey] + """ + matplotlib.rcParams['figure.figsize'] = [sizex, sizey] + + def pastefig(*figs): """Paste one or more figures into the console workspace. @@ -68,9 +78,6 @@ def pastefig(*figs): def send_svg_canvas(canvas): """Draw the current canvas and send it as an SVG payload. """ - # Make the background transparent. - # figure_manager.canvas.figure.patch.set_alpha(0.0) - # Set the background to white instead so it looks good on black. We store # the current values to restore them at the end. fc = canvas.figure.get_facecolor()