Adding plot 4, and changing all .R files to define functions.