Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def plot_idx(df,image):
- # reset the default parameters
- plt.rcParams['font.size'] = 8.
- plt.rcParams['figure.figsize'] = (8.267, 11.692) #aA paper
- fig = plt.figure()
- #plot all the 6 figures for 30/90/180...AllTime and save the image
- ax1 = fig.add_subplot(321) # first row first image
- x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-1])
- ax1.plot(x, y,'r')
- ax1.plot(x_min,y_min,'o')
- ax1.plot(x_max,y_max,'o')
- ax1.set_xlabel('year')
- ax1.set_ylabel('Index Close')
- ax1.set_title(plot_title[-1])
- ax1.fill_between(x,y,facecolor='red')
- ax2 = fig.add_subplot(322) # first row second image
- x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-2])
- ax2.plot(x, y,'r')
- ax2.plot(x_min,y_min,'o')
- ax2.plot(x_max,y_max,'o')
- ax2.set_xlabel('year')
- ax2.set_ylabel('Index Close')
- ax2.set_title(plot_title[-2])
- ax2.fill_between(x,y,facecolor='red')
- # ax2.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
- ax3 = fig.add_subplot(323) # 2nd row first image
- x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-3])
- ax3.plot(x, y,'r')
- ax3.plot(x_min,y_min,'o')
- ax3.plot(x_max,y_max,'o')
- ax3.set_xlabel('year')
- ax3.set_ylabel('Index Close')
- ax3.set_title(plot_title[-3])
- ax3.fill_between(x,y,facecolor='red')
- ax3.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
- ax4 = fig.add_subplot(324) # 2nd row second image
- x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-4])
- ax4.plot(x, y,'r')
- ax4.plot(x_min,y_min,'o')
- ax4.plot(x_max,y_max,'o')
- ax4.set_xlabel('year')
- ax4.set_ylabel('Index Close')
- ax4.set_title(plot_title[-4])
- ax4.fill_between(x,y,facecolor='red')
- ax4.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
- ax5 = fig.add_subplot(325) # 3rd row first image
- x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-5])
- ax5.plot(x, y,'r')
- ax5.plot(x_min,y_min,'o')
- ax5.plot(x_max,y_max,'o')
- ax5.set_xlabel('year')
- ax5.set_ylabel('Index Close')
- ax5.set_title(plot_title[-5])
- ax5.fill_between(x,y,facecolor='red')
- ax5.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
- ax6 = fig.add_subplot(326) # 3rd row second image
- x,y,x_min, y_min, x_max, y_max = min_max(df,time_slice[-6])
- ax6.plot(x, y,'r')
- ax6.plot(x_min,y_min,'o')
- ax6.plot(x_max,y_max,'o')
- ax6.set_xlabel('year')
- ax6.set_ylabel('Index Close')
- ax6.set_title(plot_title[-6])
- ax6.fill_between(x,y,facecolor='red')
- ax6.axis([x[1], x[-1], 0.8 * y_min, 1.1 * y_max])
- plt.tight_layout()
- plt.savefig(image)
Advertisement
Add Comment
Please, Sign In to add comment