part 1 code and plots