Code and plots for assignment