Made changes to teh code to plot in the files directly.