up

Matplotlib Tricks

Creating nice graphics from your results (which look the way you intend them to) can sometimes be tricky. Here I will collect nice tricks for tweaking Matplotlib. If you have something to contribute to this collection please send me an email

Adding all kinds of stuff to your plots

Drawing shapes (like arrows) or text into a pylab-plot is actually quite simple. However, instead of using the pylab-frontend for matplotlib it requires direct access to the object oriented matplotlib (which is hidden behind pylab).
Basically you simply generate an "Artist" object and add it to your plot. In my current solution to problem set 1 you find an example for this. You can find the possible artists in the class documentation of matplotlib. In the example I used a Text and an Arrow object.

Animations

Take a look at this Cookbook entry on how to create animated plots.

Clear a Figure

If you want to know how to clear a figure in Matplotlib take a look at
this thread.

3d plots

There is a subpackage called axes3d in matplotlib which allows you to do different kinds of 3d plots. An introduction an be found here. I also created a short example file for plotting a mesh in 3d.

Motion Graphics with Python (independent of Matplotlib)

I found a very nice tutorial about creating graphics with Python here. There is also a section on creating movies from image sequences using ffmpeg. (If ffmpeg is not installed on your computer you can google for binaries.)

Print quality outout using LaTeX

Though I have not tried it yet this seems to be a good way of producing print quality graphics, which can then be embedded in LaTeX documents.