added function to plot to pdf pages