IPython Documentation

Table Of Contents

Previous topic

core.prompts

Next topic

core.shellapp

This Page

core.pylabtools

Module: core.pylabtools

Pylab (matplotlib) support utilities.

Authors

  • Fernando Perez.
  • Brian Granger

Functions

IPython.core.pylabtools.activate_matplotlib(backend)

Activate the given backend and set interactive to True.

IPython.core.pylabtools.configure_inline_support(shell, backend, user_ns=None)

Configure an IPython shell object for matplotlib use.

Parameters :

shell : InteractiveShell instance

backend : matplotlib backend

user_ns : dict

A namespace where all configured variables will be placed. If not given, the user_ns attribute of the shell object is used.

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.find_gui_and_backend(gui=None)

Given a gui string return the gui and mpl backend.

Parameters :

gui : str

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

Returns :

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

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

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.import_pylab(user_ns, import_all=True)

Import the standard pylab symbols into user_ns.

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

Convert a figure to svg or png for inline display.

IPython.core.pylabtools.pylab_activate(user_ns, gui=None, import_all=True, shell=None)

Activate pylab mode in the user’s namespace.

Loads and initializes numpy, matplotlib and friends for interactive use.

Parameters :

user_ns : dict

Namespace where the imports will occur.

gui : optional, string

A valid gui name following the conventions of the %gui magic.

import_all : optional, boolean

If true, an ‘import *‘ is done from numpy and pylab.

Returns :

The actual gui used (if not given as input, it was obtained from matplotlib :

itself, and will be needed next to configure IPython’s gui integration. :

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

Select figure format for inline backend, either ‘png’ or ‘svg’.

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