Setting the Backend for Matplotlib

The Backend that Matplotlib uses can be set in the matplotlibrc file which is located on Mac OSX is located in /Library/Frameworks/Python.framework/Versions/2.x/lib/python2.x/site-packages/matplotlib/mpl-data.

Here, the backend can be defined.

Transient

The other method for defining the backend is by adding a statement directly after importing Matplotlib and before importing any other libraries such as pylab. For Example:

import matplotlib as mpl
mpl.use( "cairo" )

To learn more about the matplotlibrc file, read this.
To learn more about the use of Backends, read this.