MatPlotLibHowTo

Revision 3 as of 2006-04-26 15:50:28

Clear message

What is matplotlib

[http://matplotlib.sourceforge.net/ Matplotlib] (AKA Pylab) is a cross platform 2d plotting library for Python.

Here's how I compiled and installed it from source.

Installing dependencies

Matplotlib works with a variety of GUI toolkits and graphical back ends. I was most interested in the GTK and Tk interface and in the AGG back end. For those, install the pygtk and tk -dev packages and their dependancies (breezy has tcl8.4)

        $ sudo apt-get install python-gtk2-dev
        $ sudo apt-get install tk8.4-dev tk8.4-doc

Read more about the available backends at [http://matplotlib.sourceforge.net/backends.html].

Installing buildtools

Ubuntu does not ship with make or gcc installed by default, and [http://checkinstall.izto.org/ checkinstall] seemed like a good idea

        $ sudo apt-get install build-essential checkinstall

Read more about compiling things on Ubuntu at CompilingEasyHowTo.

Building matplotlib

Get the latest source (matplotlib-0.86.2.tar.gz as of late January 2006) from matplotlib.sf.net, unpack it, build it and install it.

        $ tar zxf matplotlib-0.86.2.tar.gz
        $ cd matplotlib-0.86.2
        $ python setup.py build
        $ sudo checkinstall python setup.py install

Type whatever you like in the various package fields when checkinstall asks. If you're going to share the resulting package with others then try to be accurate, particulary in the license field, so as to not give the wrong impression.

checkinstall creates a debian package from what "python setup.py install" installed. You can use that package to remove those files from your system using "dpkg -r matplotlib-0.86.2". Here are two ways to see what's in that package (which is now installed, and a copy of which is in the matplotlib-0.86.2 source directory).

        $ dpkg -L matplotlib-0.86.2 | less
        $ dpkg --contents matplotlib-0.86.2_0.86.2-1_i386.deb | less

Using matplotlib

Copy the sample matplotlibrc file from the matplotlib-0.86.2 directory to ~/.matplotlib/matplotlibrc

I edited matplotlibrc changing the line

numerix      : numarray    # numpy, Numeric or numarray

to

numerix      : Numeric    # numpy, Numeric or numarray

since Numeric is already used in other parts of my application.

Run some of the examples in matplotlib-0.86.2/examples to check that it works. For example

        python integral_demo.py

There is a [http://matplotlib.sourceforge.net/tutorial.html tutorial] on the matplotlib home page and a [http://new.scipy.org/Wiki/Cookbook/Matplotlib cookbook] on the new SciPy wiki.


CategoryDocumentation CategoryCleanup