30 second tutorial for ipython, pylab, numpy and matplotlib

ipython & pylab, especially when you include numpy and matplotlib, make a fantastic replacement for gnuplot. Imagine if you had the plotting capabilities of Mathematica, but the ease of use of Python. Thats what this combo gives you.

First, you need to install all the right bits. I’ve got links above, and each link should have a good install tutorial. For linux distributions, this is particularly easy. Just use yum or apt-get.

Start off by running the interactive ipython shell in pylab mode:

# ipython -pylab

Then, once you’re there, lets do a simple plot:

>> your_data = load(”./datafile”)
>> plot(your_data);
>> legend()

The file ‘datafile’ could look something like this:

1 2 3
2 3 4
3 2 3
4 1 2
5 0 1
6 1 0
7 2 1
8 3 2
9 2 3

The plot() function will pop up a window that looks like this:

Pretty easy, huh?

The great part about this combination is the number of other transformations that you can do on the data. So, any sort of other data analysis that you’d like to do (sorting, contour, histogramming, etc.) is all built in to either matplotlib, numpy, or pylab. Excellent!

Tags: , , , ,

One Response to “30 second tutorial for ipython, pylab, numpy and matplotlib”

  1. Robert Says:

    Have you looked at R from GNU? It is like the old S language.
    It probably isn’t a good replacement for you but it is interesting
    to look at.

Leave a Reply