code for plots 1-4