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.
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" )