2010/05/10

  1. #!/usr/bin/env python  
  2.   
  3. import fileinput   
  4. import pylab  
  5. import matplotlib.pyplot as plt  
  6. from matplotlib import rc  
  7. from math import *  
  8. fig_width_pt = 246.0  # Get this from LaTeX using \showthe\columnwidth  
  9. inches_per_pt = 1.0/72.27               # Convert pt to inch  
  10. golden_mean = (sqrt(5)-1.0)/2.0         # Aesthetic ratio  
  11. fig_width = fig_width_pt*inches_per_pt  # width in inches  
  12. fig_height = fig_width*golden_mean      # height in inches  
  13. fig_size =  [fig_width,fig_height]  
  14. params = {'backend''ps',  
  15.            'axes.labelsize'20,  
  16.            'text.fontsize'20,  
  17.            'legend.fontsize'20,  
  18.            'xtick.labelsize'20,  
  19.            'ytick.labelsize'20,  
  20.            'text.usetex'True,  
  21.            'figure.figsize': fig_size}  
  22. pylab.rcParams.update(params)  
  23.   
  24. #rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})  
  25. ## for Palatino and other serif fonts use:  
  26. rc('text', usetex=True)  
  27. rc('font', family='serif')  
  28.   
  29.   
  30. time_s=[]  
  31. spot_p=[]  
  32. forward_p=[]  
  33. b_theta=[]  
  34. kappa=[]  
  35. for line in fileinput.input():  
  36.     items=line[:-1].split()  
  37.     spot_p.append(items[0])  
  38.     forward_p.append(items[1])  
  39.     b_theta.append(items[2])  
  40.     time_s.append(items[4])  
  41.     kappa.append(items[5])  
  42.     print items[0],items[1],items[2],items[3],items[4],items[5]  
  43.   
  44.   
  45. fig = pylab.figure(1, figsize=(13,10))  
  46. plt.xlabel('Time to maturity')  
  47. plt.ylabel('Prices')  
  48. plt.plot(time_s,spot_p,label='Spot price')  
  49. plt.plot(time_s,forward_p,label='Forward price')  
  50. plt.legend()  
  51. plt.xlim([01.6])  
  52. #plt.show()  
  53. plt.savefig('price_his.eps')  
  54.   
  55.   
  56. fig = pylab.figure(2,figsize=(13,10))  
  57. plt.xlabel('Time to maturity')  
  58. plt.ylabel(r'$\kappa$')  
  59. plt.plot(time_s,kappa,label=r'$\kappa$')  
  60. plt.legend()  
  61. plt.xlim([01.6])  
  62. plt.ylim([-105])  
  63. #plt.show()  
  64. plt.savefig('kappa.eps')  
  65.   
  66.   
  67. fig = pylab.figure(3,figsize=(13,10))  
  68. plt.xlabel('Time to maturity')  
  69. plt.ylabel(r'$\bar{\theta}$')  
  70. plt.plot(time_s,b_theta,label=r'$\bar{\theta}$')  
  71. plt.legend()  
  72. #plt.xlim([0, 1.6])  
  73. #plt.ylim([-10, 5])  
  74. #plt.show()  
  75. plt.savefig('b_theta.eps')  



 
Posted by Picasa