problems with plot and twinx


I am having some trouble with the syntax for plotting using matplotlib. I
have appended a simple script which illustrates the problem. When I run
the script the first plot command gives the expected results but the
second, third and fourth plot commands do not. The second window does
open but no plots are contained within. However if I read the script
again (run ....) but do not call the function (main()) then the plots for
the second window appear (but the plot in the first window does not get
the second plot).

Any help?

#!/usr/bin/env ipython

from __future__ import division

import numpy as np
import scipy as sp
#import matplotlib.pyplot as plt
import matplotlib.pylab as plt

def main():

  a = np.array([1,2,3])
  b = np.array(([100,200,300],[400,500,600],[700,800,900]))

  fig1 = plt.figure(1)

  ax1 = fig1.add_subplot(111)

  ax2 = plt.twinx()

  fig2 = plt.figure(2)

  ax3 = fig2.add_subplot(211)

  ax4 = fig2.add_subplot(212)