Hello:
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)
ax1.plot(a)
ax1.set_xlabel('x')
ax1.set_ylabel('y')
ax2 = plt.twinx()
ax2.plot(b[:,:])
ax2.set_ylabel('x')
ax2.yaxis.tick_right()
fig2 = plt.figure(2)
ax3 = fig2.add_subplot(211)
ax3.plot(a)
ax3.set_xlabel('x')
ax3.set_ylabel('y')
ax4 = fig2.add_subplot(212)
ax4.plot(b[1,:])
ax4.set_xlabel('x')
ax4.set_ylabel('y')
plt.show()
return