1. when running ipython without pylab or executing scripts you want to use an image matplotlib backend like Agg

  2. just when calling ipython -pylab you want to use an interactive backend like GTKAgg or TKAgg

you need first to setup as default backend on .matplotlib/matplotlibrc Agg :
backend : Agg
then setup you ipython to switch to interactive, in ipython file Shell.py, in the class MatplotlibShellBase, at about line 516, add:
after the first import of matplotlib