Added new function for writing plot to file.
Implemented 1st and 2nd plots.