IPython Documentation

Table Of Contents

Previous topic

Module: core.prompts

Next topic

Module: core.shellapp

This Page

Module: core.pylabtools

Pylab (matplotlib) support utilities.

Authors

  • Fernando Perez.
  • Brian Granger

10 Functions

IPython.core.pylabtools.getfigs(*fig_nums)

Get a list of matplotlib figures by figure numbers.

If no arguments are given, all available figures are returned. If the argument list contains references to invalid figures, a warning is printed but the function continues pasting further figures.

Parameters:

figs : tuple

A tuple of ints giving the figure numbers of the figures to return.

IPython.core.pylabtools.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]
IPython.core.pylabtools.print_figure(fig, fmt='png')

Convert a figure to svg or png for inline display.

IPython.core.pylabtools.retina_figure(fig)

format a figure as a pixel-doubled (retina) PNG

IPython.core.pylabtools.mpl_runner(safe_execfile)

Factory to return a matplotlib-enabled runner for %run.

Parameters:

safe_execfile : function

This must be a function with the same interface as the safe_execfile() method of IPython.

Returns:

A function suitable for use as the ``runner`` argument of the %run magic :

function. :

IPython.core.pylabtools.select_figure_format(shell, fmt)

Select figure format for inline backend, can be ‘png’, ‘retina’, or ‘svg’.

Using this method ensures only one figure format is active at a time.

IPython.core.pylabtools.find_gui_and_backend(gui=None, gui_select=None)

Given a gui string return the gui and mpl backend.

Parameters:

gui : str

Can be one of (‘tk’,’gtk’,’wx’,’qt’,’qt4’,’inline’).

gui_select : str

Can be one of (‘tk’,’gtk’,’wx’,’qt’,’qt4’,’inline’). This is any gui already selected by the shell.

Returns:

A tuple of (gui, backend) where backend is one of (‘TkAgg’,’GTKAgg’, :

‘WXAgg’,’Qt4Agg’,’module://IPython.kernel.zmq.pylab.backend_inline’). :

IPython.core.pylabtools.activate_matplotlib(backend)

Activate the given backend and set interactive to True.

IPython.core.pylabtools.import_pylab(user_ns, import_all=True)

Populate the namespace with pylab-related values.

Imports matplotlib, pylab, numpy, and everything from pylab and numpy.

Also imports a few names from IPython (figsize, display, getfigs)

IPython.core.pylabtools.configure_inline_support(shell, backend)

Configure an IPython shell object for matplotlib use.

Parameters:

shell : InteractiveShell instance

backend : matplotlib backend