Guest User

matplotlib 6 fig plot

a guest
Jul 24th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.61 KB | None | 0 0
  1. def plot_idx(df,image):
  2.     # reset the default parameters
  3.     plt.rcParams['font.size'] = 8.
  4.     plt.rcParams['figure.figsize'] = (8.267, 11.692) #aA paper
  5.     fig = plt.figure()
  6. #plot all the 6 figures for 30/90/180...AllTime and save the image
  7.  
  8.     ax1 = fig.add_subplot(321) # first row first image
  9.     x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-1])
  10.     ax1.plot(x, y,'r')
  11.     ax1.plot(x_min,y_min,'o')
  12.     ax1.plot(x_max,y_max,'o')
  13.     ax1.set_xlabel('year')
  14.     ax1.set_ylabel('Index Close')
  15.     ax1.set_title(plot_title[-1])
  16.     ax1.fill_between(x,y,facecolor='red')
  17.  
  18.     ax2 = fig.add_subplot(322) # first row second image
  19.     x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-2])
  20.     ax2.plot(x, y,'r')
  21.     ax2.plot(x_min,y_min,'o')
  22.     ax2.plot(x_max,y_max,'o')
  23.     ax2.set_xlabel('year')
  24.     ax2.set_ylabel('Index Close')
  25.     ax2.set_title(plot_title[-2])
  26.     ax2.fill_between(x,y,facecolor='red')
  27. #    ax2.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
  28.  
  29.     ax3 = fig.add_subplot(323) # 2nd row first image
  30.     x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-3])
  31.     ax3.plot(x, y,'r')
  32.     ax3.plot(x_min,y_min,'o')
  33.     ax3.plot(x_max,y_max,'o')
  34.     ax3.set_xlabel('year')
  35.     ax3.set_ylabel('Index Close')
  36.     ax3.set_title(plot_title[-3])
  37.     ax3.fill_between(x,y,facecolor='red')
  38.     ax3.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
  39.  
  40.     ax4 = fig.add_subplot(324) # 2nd row second image
  41.     x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-4])
  42.     ax4.plot(x, y,'r')
  43.     ax4.plot(x_min,y_min,'o')
  44.     ax4.plot(x_max,y_max,'o')
  45.     ax4.set_xlabel('year')
  46.     ax4.set_ylabel('Index Close')
  47.     ax4.set_title(plot_title[-4])
  48.     ax4.fill_between(x,y,facecolor='red')
  49.     ax4.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
  50.  
  51.     ax5 = fig.add_subplot(325) # 3rd row first image
  52.     x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-5])
  53.     ax5.plot(x, y,'r')
  54.     ax5.plot(x_min,y_min,'o')
  55.     ax5.plot(x_max,y_max,'o')
  56.     ax5.set_xlabel('year')
  57.     ax5.set_ylabel('Index Close')
  58.     ax5.set_title(plot_title[-5])
  59.     ax5.fill_between(x,y,facecolor='red')
  60.     ax5.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
  61.  
  62.     ax6 = fig.add_subplot(326) # 3rd row second image
  63.     x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-6])
  64.     ax6.plot(x, y,'r')
  65.     ax6.plot(x_min,y_min,'o')
  66.     ax6.plot(x_max,y_max,'o')
  67.     ax6.set_xlabel('year')
  68.     ax6.set_ylabel('Index Close')
  69.     ax6.set_title(plot_title[-6])
  70.     ax6.fill_between(x,y,facecolor='red')
  71.     ax6.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
  72.  
  73.     plt.tight_layout()
  74.     plt.savefig(image)
Advertisement
Add Comment
Please, Sign In to add comment