Code and figures for plots 1-3